Duck Typing and **kwds
Eduardo O. Padoan
eduardo.padoan at gmail.com
Thu Oct 11 08:53:57 EDT 2007
More information about the Python-list mailing list
Thu Oct 11 08:53:57 EDT 2007
- Previous message (by thread): Duck Typing and **kwds
- Next message (by thread): Fwd: NUCULAR fielded text searchable indexing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 10/11/07, Luis Zarrabeitia <kyrie at uh.cu> wrote: > > Hi there. > > I just tried this test: > > ==== > def f(**kwds): > print kwds > > import UserDict > d = UserDict.UserDict(hello="world") > f(**d) > ==== > > And it fails with a TypeError exception ("f() argument after ** must be a > dictionary"). I find that weird, as UserDict should support all protocols that > dict supports, yet it doesn't seem to support ** unpacking. If instead of > UserDict I use a derivate class from dict (class mydict(dict):pass), the ** > operator works as expected. It also works if I execute f(**dict(d)) instead. > > Is that behavior expected? Is there any reason (performance, perhaps?) to break > duck-typing in this situation? Reported, accepted and closed 5 months ago: http://bugs.python.org/issue1686487 -- http://www.advogato.org/person/eopadoan/ Bookmarks: http://del.icio.us/edcrypt
- Previous message (by thread): Duck Typing and **kwds
- Next message (by thread): Fwd: NUCULAR fielded text searchable indexing
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list