467,894 Members | 1,751 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,894 developers. It's quick & easy.

Name of function caller

Is there a way that a function may access the doc string or func_name
of the caller?

Thanks,

jvh

May 15 '07 #1
  • viewed: 1300
Share:
4 Replies
On May 15, 4:59 pm, HMS Surprise <j...@datavoiceint.comwrote:
Is there a way that a function may access the doc string or func_name
of the caller?

Thanks,

jvh
Yes. The inspect module allows you to look up the call stack for
information on the caller, the caller's caller, local vars, etc.

-- Paul

May 15 '07 #2
On May 15, 5:13 pm, Paul McGuire <p...@austin.rr.comwrote:
On May 15, 4:59 pm, HMS Surprise <j...@datavoiceint.comwrote:
Is there a way that a function may access the doc string or func_name
of the caller?
Thanks,
jvh

Yes. The inspect module allows you to look up the call stack for
information on the caller, the caller's caller, local vars, etc.

-- Paul
Thanks Paul.

Running jython 2.2. No module named inspect or cInspect
drat...

May 15 '07 #3
On May 16, 8:56 am, HMS Surprise <j...@datavoiceint.comwrote:
On May 15, 5:13 pm, Paul McGuire <p...@austin.rr.comwrote:
On May 15, 4:59 pm, HMS Surprise <j...@datavoiceint.comwrote:
Is there a way that a function may access the doc string or func_name
of the caller?
Thanks,
jvh
Yes. The inspect module allows you to look up the call stack for
information on the caller, the caller's caller, local vars, etc.
-- Paul

Thanks Paul.

Running jython 2.2. No module named inspect or cInspect

drat...
According to the current docs, inspect was new in Python 2.1. You've
been in more strife than Paris Hilton recently and it's hard to keep
track, but IIRC you're the guy with the badly-stuffed sys.path ...
have a look on your disk(s). OTOH maybe inspect depends on the
internal call stack implementation --- in that case you would need to
ask on the jython mailing-list.

HTH,
John
May 15 '07 #4
HMS Surprise wrote:
Is there a way that a function may access the doc string or func_name
of the caller?

Thanks,

jvh
Add a parameter to the function to avoid mutilating your code with
implementation specific inspection:

def fun(caller, *original_parameters):
do_something_to_caller_without_magic(caller)
do_something_with_original_parameters(*original_pa rameters)

James
May 15 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Gnanaprakash Rathinam | last post: by
4 posts views Thread by Thomas Mlynarczyk | last post: by
17 posts views Thread by warteschlange | last post: by
45 posts views Thread by Zytan | last post: by
7 posts views Thread by jackchang1 | last post: by
7 posts views Thread by =?UTF-8?B?QW50w7NuaW8gTWFycXVlcw==?= | last post: by
185 posts views Thread by jacob navia | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.