Question about extending the interperter

harold fellermann harold.fellermann at upf.edu
Tue May 10 09:09:31 EDT 2005


> The problem for me is that the pointer "p" in the last function points
> to the arguments:
> If a user caller foo("123") - p points to '123'.
> What I need is to point it to the whole string received - 'foo
> ("123")'.
>
> Is there a way I can do this?

no. at least not a simple one. you can obtain the function name by 
func_name,
as the corresponding python code suggests:
 >>> def f() :
...     pass
...
 >>> print f.func_name
f

However, you still don't know, how the function has been invoked.
Consider:

 >>> g=f
 >>> print g.func_name
f

of course, the situation can be much more sphisticated. f could be a 
value
in a dict returned by some other function, and so on. Of course there 
are
ways to inspect the source code (like pdb or exceptions do), but are you
sure this is the functionality to want?

Cheers,

- harold -

--
Learn from the mistakes of others.
You can't live long enough to make them all yourself.
--




More information about the Python-list mailing list