Python Forum
collector of a bunch of named stuff - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: News and Discussions (https://python-forum.io/forum-31.html)
+--- Thread: collector of a bunch of named stuff (/thread-13125.html)



collector of a bunch of named stuff - Skaperen - Sep-28-2018

can someone tell me how it is that this work?

http://code.activestate.com/recipes/52308-the-simple-but-handy-collector-of-a-bunch-of-named/?in=user-9799


RE: collector of a bunch of named stuff - ichabod801 - Sep-29-2018

**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.