Re: naming objects from string
"James Stroud" <jstroud@mbi.uc la.eduwrote in message
news:zvoQg.3828 $e66.1118@newss vr13.news.prodi gy.com...
If you put this code within a function, it probably will not work.
locals() is usually a *copy* of the local namespace and writes do not write
back to the namespace itself.
tjr
"James Stroud" <jstroud@mbi.uc la.eduwrote in message
news:zvoQg.3828 $e66.1118@newss vr13.news.prodi gy.com...
Depends on your namespace, but for the local namespace, you can use this:
>
pya = object()
pya
<object object at 0x40077478>
pylocals()['bob'] = a
pybob
<object object at 0x40077478>
>
pya = object()
pya
<object object at 0x40077478>
pylocals()['bob'] = a
pybob
<object object at 0x40077478>
locals() is usually a *copy* of the local namespace and writes do not write
back to the namespace itself.
tjr
Comment