naming objects from string

Damjan gdamjan at gmail.com
Thu Sep 21 06:53:08 CEST 2006


manstey wrote:

> Hi,
> 
> But this doesn't work if I do:
> 
> a=object()
> x='bob'
>  locals()[x] = a
>
> How can I do this?

try
sys.modules[__name__].__dict__[x] = a

But what's the point?


-- 
damjan



More information about the Python-list mailing list