On Fri, 21 Oct 2005 13:33:18 -0400, Mike Meyer wrote: > Paul Dale <[EMAIL PROTECTED]> writes: > >> Hi everyone, >> >> Is it possible to bind a list member or variable to a variable such that >> >> temp = 5 >> >> list = [ temp ]
Don't use the names of built-in functions as variables. >> temp == 6 >> >> list >> >> would show >> >> list = [ 6 ] > > No. You need to either put a mutable in the list, or subclass list so > that indexing gets the value, looks it up in the appropriate > namespace, and returns that value. Or something even conceptually simpler than having to muck about with looking up different namespaces: class Data: def __init__(self, obj): self.value = obj def __str__(self): return self.value temp = Data(5) L = [temp] print L will give 5. temp.value = 6 print L will now give 6. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list