[EMAIL PROTECTED] wrote: > Does Python provide some sort of mechanism for answering the question: > what method am I in? > > Example: assume the file example1.py contains the following code: > > def driver(): > print 'hello world' > print __name__ > print 'the name of this method is %s' % str(???) > > The output I'd like to see is: > > hello world > example1 > driver > > and I'd like to be able to see it without hardcoding the string > 'driver' in the third print statement. Is there anything I can > substitute for the ??? that answers the question: what method am I in?
replace str(???) with (sys._getframe().f_code.co_name or "???") </F> -- http://mail.python.org/mailman/listinfo/python-list