Re: Getting external name of passed variable

2006-06-20 Thread David Hirschfield
Cool, thanks. Stack inspection of sorts it is. -Dave faulkner wrote: import sys tellme = lambda x: [k for k, v in sys._getframe(1).f_locals.iteritems() if v == x] a=1 tellme(a) ['a'] Michael Spencer wrote: David Hirschfield wrote:

Re: Getting external name of passed variable

2006-06-20 Thread faulkner
>>> import sys >>> tellme = lambda x: [k for k, v in sys._getframe(1).f_locals.iteritems() if >>> v == x] >>> a=1 >>> tellme(a) ['a'] Michael Spencer wrote: > David Hirschfield wrote: > > I'm not sure this is possible, but it sure would help me if I could do it. > > > > Can a function learn the n

Re: Getting external name of passed variable

2006-06-20 Thread Michael Spencer
David Hirschfield wrote: > I'm not sure this is possible, but it sure would help me if I could do it. > > Can a function learn the name of the variable that the caller used to > pass it a value? For example: > > def test(x): > print x > > val = 100 > test(val) > > Is it possible for function

Getting external name of passed variable

2006-06-20 Thread David Hirschfield
I'm not sure this is possible, but it sure would help me if I could do it. Can a function learn the name of the variable that the caller used to pass it a value? For example: def test(x):    print x val = 100 test(val) Is it possible for function "test()" to find out that the variable