At Thursday 21/9/2006 00:59, manstey wrote:

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?

You may use another object as a namespace:

class X: pass
x = X()

a = 'hello'
b = (1,2,3,4)
setattr(x, a, b)

print x.hello # prints (1,2,3,4)
getattr(x, a) # returns the same

but perhaps if you explain better what you want, we can figure out how to do that...



Gabriel Genellina
Softlab SRL

        
        
                
__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya! http://www.yahoo.com.ar/respuestas

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to