2010/2/13 Kent Johnson <ken...@tds.net> > > > >Here is a way to do it using the traceback module. Under the hood it > >is still using implementation details contained in traceback and stack > >frame objects but the public interface in the traceback module should > >be stable. > > >import sys, traceback > > >def whoami(): > > stack = traceback.extract_stack(limit=2) > > print "Who call me ? : ", stack[0][2] > > print "Who am I ? : ", stack[1][2] > > >def print_caller_name(): > > whoami() > > >if __name__ == "__main__": > > print_caller_name() > > >Kent > Thanks for the help, I will look closer at the traceback module and at your solution
Patrice
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor