function call

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Tue Sep 4 17:17:09 EDT 2007


On Tue, 04 Sep 2007 13:17:39 -0700, ianaré wrote:

> Hey all,
> 
> Is there a way of printing out how a function was called? In other words
> if I do the following:
> 
> def someFunction(self):
>     self.someOtherFunction(var1, var2)
> 
> 
> I would get something like "someOtherFunction: called by: someFunction,
> args are: var1, var2"

The obvious way is:

def someFunction(self):
    print "someOtherFunction: called by: someFunction," \
    "args are: %s, %s" % (var1, var2)
    self.someOtherFunction(var1, var2)

but that has obvious inconveniences. 

Perhaps you should look at the Python debugger and profiler? Do they 
solve the underlying problem you are trying to solve?



-- 
Steven.



More information about the Python-list mailing list