On Wed, 23 Mar 2005 11:35:34 +0100 kramb64 wrote: K> I'm trying to use setattr inside a module. K> >From outside a module it's easy: K> K> import spam K> name="hello" K> value=1 K> setattr(spam, name, value) K> K> But if I want to do this inside the module spam itself, what I've to K> pass to setattr as first argument?
globals()[name] = value or setattr(__import__(__name__), name, value) # note, circular import here -- Denis S. Otkidach http://www.python.ru/ [ru] -- http://mail.python.org/mailman/listinfo/python-list