Getting a class name

goodwolf Robert.Katic at gmail.com
Sun Feb 18 02:20:33 EST 2007


I suppose that you wont get class name into its code (or before
definition end) but not into a method definition.


import sys

def getCodeName(deap=0):
    return sys._getframe(deap+1).f_code.co_name


class MyClass (object):
    name = getCodeName() + '!'





More information about the Python-list mailing list