naming objects from string
timr at probo.com
Thu Sep 21 08:39:19 CEST 2006
"manstey" <manstey at csu.edu.au> wrote:
>If I have a string, how can I give that string name to a python object,
>such as a tuple.
>a = 'hello'
That's not a tuple. That's an integer. (1234,) is a tuple.
>and then a function
>name(b) = a
>which would mean:
>is this possible?
Yes, but it's almost never the right way to solve your problem. Use an
explicit dictionary instead.
Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)]
Type "help", "copyright", "credits" or "license" for more information.
>>> locals()[a] = 1234
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list