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
> 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
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
>
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
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
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