Re: naming objects from string
- From: James Stroud <jstroud@xxxxxxxxxxxx>
- Date: Thu, 21 Sep 2006 04:26:07 GMT
manstey wrote:
Hi,
If I have a string, how can I give that string name to a python object,
such as a tuple.
e.g.
a = 'hello'
b=(1234)
and then a function
name(b) = a
which would mean:
hello=(1234)
is this possible?
Depends on your namespace, but for the local namespace, you can use this:
py> a = object()
py> a
<object object at 0x40077478>
py> locals()['bob'] = a
py> bob
<object object at 0x40077478>
A similar approach can be used for the global namespace.
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
.
- Follow-Ups:
- Re: naming objects from string
- From: Terry Reedy
- Re: naming objects from string
- From: manstey
- Re: naming objects from string
- References:
- naming objects from string
- From: manstey
- naming objects from string
- Prev by Date: naming objects from string
- Next by Date: i just made a website(ztooo.com) using zope & jsonserver
- Previous by thread: naming objects from string
- Next by thread: Re: naming objects from string
- Index(es):
Relevant Pages
|