Printing variable names
Nuff Said
nuffsaid at phreaker.net
Sun Jan 18 15:16:27 EST 2004
On Sun, 18 Jan 2004 11:22:08 -0800, Mike wrote:
> mylist = [a, b, c]
>
> I want to print out the names of the variables in mylist (not the
> values of a, b, and c). How do I go about doing this. Thanks.
The following example shows that this does not really make sense:
a = 1; b = 2; c = 3;
mylist = [a, b, c]
a = 4; b = 5; c = 6;
print mylist
print a, b, c
Result:
[1, 2, 3]
4 5 6
and *not*:
[4, 5, 6]
4 5 6
You might want to google for 'Python object reference' etc.
Moreover, having a look (e.g. in the tutorial) at how Python
passes arguments to functions (mutable and immutable objects)
might help to get a better understanding of what is going on
behind the scenes.
HTH / Nuff
More information about the Python-list
mailing list