Can you obtain names from parent scope?
Michael Hudson
mwh at python.net
Fri Jan 17 11:38:08 EST 2003
wsadkin at nameconnector.com (Will Sadkin) writes:
> However I can't make this work, because objects don't have any
> intrinsic name, and if I write a function of the form
> >>> def dbgval(*args):
> ...
>
> then dbgval() only knows the arguments objects as belonging to the
> list 'args', and I can't find any way to determine what the names
> were in the parent's local scope when the function was called.
How did you know they had any?
dbgval({})
> Is there any way for a function to retrieve this information?
Well, you can hack around in the bytecode. I've posted code to do it
to c.l.py before -- hit google if you like.
Cheers,
M.
--
Java is a WORA language! (Write Once, Run Away)
-- James Vandenberg (on progstone at egroups.com)
& quoted by David Rush on comp.lang.scheme
More information about the Python-list
mailing list