473,322 Members | 1,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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
4 1436
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marek Prerovsky | last post by:
Hello, I implemented some Python functions in my C/C++ code. I need to know the Python source file name and line number of just executed Python command which calls my function. How can I get...
4
by: Gnanaprakash Rathinam | last post by:
Hi Expert, Is there a way to obtain assembly name in an unmanaged call? During Interop call between managed to unmanaged, I would like to know in unmanaged code about the caller of assembly file...
4
by: Thomas Mlynarczyk | last post by:
Hi, I stumbled over a strange behaviour of Mozilla. When I want to access the caller property of a function that was not called from within another function, Mozilla seems to abort the script....
17
by: warteschlange | last post by:
is there a way to find out the object/function name from inside object/function. function coffee(){ alert(this.someHowGetMyNameFuncOrVar); => should give me 'coffee' } var milk = new...
3
by: Rico | last post by:
Hello, I have a generic process that logs errors from different sources. When I call this code, I'd like to also submit the name of the function or sub that is raising the error without having...
45
by: Zytan | last post by:
Shot in the dark, since I know C# doesn't have macros, and thus can't have a stringizer operator, but I know that you can get the name of enums as strings, so maybe you can do the same with an...
7
by: jackchang1 | last post by:
It's not difficult getting the function name of the caller but if the caller is an object's method, how do you get the method name? <html> <head> <script type="text/javascript"> function...
7
by: =?UTF-8?B?QW50w7NuaW8gTWFycXVlcw==?= | last post by:
Hi, Sorry if this's been discussed before, I couldn't find it. As well you know, the ECMAScript standard doesn't include any way to access a function's caller. This has been available on Mozilla...
185
by: jacob navia | last post by:
Hi We are rewriting the libc for the 64 bit version of lcc-win and we have added a new field in the FILE structure: char *FileName; fopen() will save the file name and an accessor function will...
9
by: Erwin Moller | last post by:
Hi all, Is it possible (PHP5.2) to find the name of a variable used in the caller of a function from within the function itself? Or to be more clear: ...php code.. $result = foo($abc);...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.