Python Forum
collector of a bunch of named stuff
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
collector of a bunch of named stuff
#1
can someone tell me how it is that this work?

http://code.activestate.com/recipes/5230...=user-9799
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
**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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trusting the garbage collector Mekire 3 2,757 Mar-29-2018, 04:20 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020