variables - How can I get a list of references of an object in Python? -


all:

a = 1 b = c = b 

now want list of object 1 tagged, [a, b, c]. how this?

btw, how call variable "a" here officially? know far "object tag" object, have no idea term of it.

thanks!

why need this:

a = b = c = 1  print a, b, c  1 1 1 = 2 print a, b, c  2 1 1 

in other language such c, a,b,c should 2 if re-assign = 2, in python, there's no such thing reference, way change value of b c = b = c = 2 far know, why purposed reference of object.

what you're asking isn't practical , isn't possible. here's 1 crazy way of doing it:

>>> = 1 >>> b = >>> c = b >>> locals() {'a': 1, 'c': 1, 'b': 1, '__builtins__': <module '__builtin__' (built-in)>, '__package__': none, '__name__': '__main__', '__doc__': none} >>> [key key, value in locals().items() if value == 1] ['a', 'c', 'b'] >>> globals() {'a': 1, 'c': 1, 'b': 1, '__builtins__': <module '__builtin__' (built-in)>, '__package__': none, '__name__': '__main__', '__doc__': none} >>> [key key, value in globals().items() if value == 1] ['a', 'c', 'b'] 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -