> 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():
>
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
--- 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
--- 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
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
_