Re: setattr inside a module

2005-03-23 Thread Jeremy Bowers
On Wed, 23 Mar 2005 11:35:34 +0100, kramb64 wrote: > I'm trying to use setattr inside a module. > From outside a module it's easy: > > import spam > name="hello" > value=1 > setattr(spam, name, value) > > But if I want to do this inside the module

Re: setattr inside a module

2005-03-23 Thread Diez B. Roggisch
> I found this: > setattr(__import__(__name__), name, value) > > But too much underscores Nothing better? > Marco. setattr(sys.modules[__name__], name, value) -- Regards, Diez B. Roggisch -- http://mail.python.org/mailman/listinfo/python-list

Re: setattr inside a module

2005-03-23 Thread Kay Schluehr
kramb64 wrote: > I'm trying to use setattr inside a module. > From outside a module it's easy: > > import spam > name="hello" > value=1 > setattr(spam, name, value) > > But if I want to do this inside the module spam itself, what I've to >

Re: setattr inside a module

2005-03-23 Thread kramb64
On Wed, 23 Mar 2005 11:35:34 +0100, kramb64 <[EMAIL PROTECTED]> wrote: >I'm trying to use setattr inside a module. >From outside a module it's easy: > >import spam >name="hello" >value=1 >setattr(spam, name, value) > >But if I want to do this

Re: setattr inside a module

2005-03-23 Thread Denis S. Otkidach
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 insi

setattr inside a module

2005-03-23 Thread kramb64
I'm trying to use setattr inside a module. >From outside a module it's easy: import spam name="hello" value=1 setattr(spam, name, value) But if I want to do this inside the module spam itself, what I've to pass to setattr as first argument? Thanks a lot fo