getting a class attribute using a keyword argument
guy at NOSPAM.r-e-d.co.nz
Mon Jan 17 06:05:10 EST 2005
I have a list of class instances. I wish to get the appropriate class attribute
in each class instance depending on a SINGLE keyword in the calling class.
How do I get the calling method to correctly recognise the keyword as a keyword
and not a class attribute? See example code below (which doesn't work).
self.title = "test"
self.name = "name"
for key in kw:
if tocall.key == kw[key]:
which should work as such(but doesn't):
print callmethod(title = "test")
print callmethod(name = "name")
More information about the Python-list