Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
> The code below doesn't do the trick for you? > > #!/usr/bin/python > import inspect > > def master(): > print "I am the master" > slave() > > def slave(): > stack = inspect.stack() > caller = stack[1][3] > print "I am the slave; my caller was %s" % caller > > def main(): >

log caller

2007-06-27 Thread Matthew Peter
Is it possible to print the function calls to a module? Like: test.py import mymod print mymod.x() mymod.py # each time a function is called we print out the called function and module print 'Func call: %s from %s' % (???, ???) def x(): return 'hello' Where would I pick up the ??? variabl

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
--- Jay Loden <[EMAIL PROTECTED]> wrote: > > Matthew Peter wrote: > > For example, how do I get this to work? > > > > def func(): > > print "This is", __?__ > > return __caller__ > > > > def echo(): > > pri

Re: Return name of caller function?

2007-06-27 Thread Matthew Peter
--- Stephen R Laniel <[EMAIL PROTECTED]> wrote: > On Mon, Jun 25, 2007 at 06:27:29PM -0700, Matthew Peter wrote: > > For example, how do I get this to work? > > > > def func(): > > print "This is", __?__ > > return __cal

Return name of caller function?

2007-06-26 Thread Matthew Peter
For example, how do I get this to work? def func(): print "This is", __?__ return __caller__ def echo(): print "This is ", __?__ return func() >>> print echo() This is echo This is func echo _