rnd at onego.ru
Thu Aug 19 06:09:49 CEST 2004
On Wed, 18 Aug 2004, Jim Benson wrote:
I am using different approach to introspection of Python
functions and methods (not all available info output,
only name of the previously called function/method).
I am not sure if this is better than getting sys._getframe()
or not, at least it doesn't use undescore methods ;-)
and "knowns" about all invocation history at once,
could even show source code, etc.
print traceback.extract_stack()[-2] + ":", msg
Introspec('i am running')
aaa = AAA()
Introspec('I am running')
>On Wed, 18 Aug 2004, Troy Melhase wrote:
>> import sys
>> def F():
>> print sys._getframe().f_code.co_name
>> >>> F()
>indeed that works fine for getting the method name.
>Thanks to all...and apologies for taking the easy way out
>by posting to this very helpful list rather than
>doing more research with google (actually i did
>do a search for 'python class method introspection'
>before posting...i didn't look at all the returns).
Sincerely yours, Roman Suzi
rnd at onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
More information about the Python-list