Hi, I found the following to be a useful way to access arguments after
they are passed to a function that collects them with **kwds.
class namespace(dict):
def __getattr__(self, name):
return self.__getitem__(name)
def __setattr__(self, name, value):
self.__setitem__(name, value)
def __delattr__(self, name):
self.__delitem__(name)
def foo(**kwds):
kwds = namespace(kwds)
print kwds.color, kwds.size, kwds.shape etc....
foo( color='red', size='large', shape='ball', .... etc..)
It just seems awkward to have to use "string keys" in this situation.
This is easy and still retains the dictionary so it can be modified and
passed to another function or method as kwds again.
Any thoughts? Any better way to do this?
Cheers, Ron
--
http://mail.python.org/mailman/listinfo/python-list