Yes!
I do this a lot when i have deeply nested function calls
a->b->c->d->e
and need to pass args to the deep function without changing the
middle functions.
In this situation I think i would prefer this variation:
class Context(dict):
def __init__(self,**kwds):
dict.__init__(self,kwds)
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(ctx):
print ctx.color, ctx.size, ctx.shape
foo( Context(color='red', size='large', shape='ball') )
This is looking like foo should be a method of Context now,
but in my situation foo is already a method of another class.
Simon.
--
http://mail.python.org/mailman/listinfo/python-list