Jeff Shannon wrote:
Are you sure that you really need that single-element list?
No I'm not sure, I thought I found a concdition where it made a
difference while playing with it, but I don't recall just what
circumstance it was?
Don't forget, in Python, all names are references. You only have to
> There should be an easier way that doesn't require stepping though
the name list.
Trying to find names bound to a particular object is a /very/ strange
thing to want to do in Python. If this is for anything more than
debugging diagnostics, it's probably better to use a dictionary
explicitly for
Ron wrote:
def getvinfo(vars, v):
"""
vars is locals()
v is [varable]
Use an one item list to pass single varables by reference.
"""
for n in vars.keys():
if vars[n] is v[0]:
return n, v[0], type(v[0])
a = 101
b = 2.3
c = True
print getvinfo(locals(), [a]
pl wrote:
Hi all,
I followed the mails entitled 'How to turn a variable name into a
string?' in march 2005 posts as I have a similar problem.
Use the locals() function instead of globals().
Thanks by the way, I was wondering how to do this also, your post, and
Daniel pointing out 'is', helped me w
pl wrote:
I followed the mails entitled 'How to turn a variable name into a
string?' in march 2005 posts as I have a similar problem.
I have to get some list variable names at some point in my program. So
I ended up looking into globals() to get them with a small function like
this:
#!/usr/bin/pyth
pl wrote:
I have to get some list variable names at some point in my program. So
I ended up looking into globals() to get them with a small function like
this:
[...]
var = globals().keys()
for i in var :
if globdict[i] == obj:
print i
Use 'is'
Hi all,
I followed the mails entitled 'How to turn a variable name into a
string?' in march 2005 posts as I have a similar problem.
I have to get some list variable names at some point in my program. So
I ended up looking into globals() to get them with a small function like
this:
#!/usr/bin/pyth