By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,427 Members | 1,356 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,427 IT Pros & Developers. It's quick & easy.

Name of function caller

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

Thanks,

jvh

May 15 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.