Update locals() / resolved
Alex Martelli
aleax at aleax.it
Sat Apr 27 18:40:47 EDT 2002
holger krekel wrote:
...
> ok. i found a nice workaround (if one dare call it that:-)
>
> class dictlookup(type({})):
> def __getattr__(self, name):
> return self[name]
>
> then i can do:
>
> def func(...,somedict,...):
> m = dictlookup(somedict)
> ...
> m.key1
I'd implement it quite differently, myself:
class dictlookup:
def __init__(self, somedict):
self.__dict__ = somedict
Alex
More information about the Python-list
mailing list