Python Forum

Full Version: collector of a bunch of named stuff
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
can someone tell me how it is that this work?

http://code.activestate.com/recipes/5230...=user-9799
**kwds (usually **kwargs) takes the named parameters passed to the function and provides them to the function as a dictionary of the names as keys with the values passed to them. An attribute of a class instance is just key in the instance's __dict__, which is also a dictionary. That is, foo.bar is the same as foo.__dict__['bar']. So you use the update method to added the named parameters and their values to the attributes for the instance.