Robert Kern wrote: > James Stroud wrote: > > > Does anyone else find the following annoying: > > > > py> from UserDict import UserDict > > py> aud = UserDict({"a":1, "b":2}) > > py> def doit(**kwargs): > > ... print kwargs > > UserDict only exists for backwards compatibility with old code that used > it before one could subclass from dict directly. Don't use it if you can > avoid it. UserDict only ever exposed the Python-side interface of dicts. > It couldn't expose the C-side interface, and it's the C-side interface > that **kwds is using.
Which means that you can't subclass dict with, say, a lazy dictionary (that doesn't retrieve values until they're looked up) and use it with **kwargs. That bit me last year: http://groups.google.com/group/comp.lang.python/browse_frm/thread/95cfa91b732cd482/24b7e17bb395494e It would be useful in some situations to be able to do this (especially where getting the dictionary values is time-consuming and the function you're calling doesn't use all the values in the dictionary). For my particular case I had a fairly easy workaround. -- http://mail.python.org/mailman/listinfo/python-list