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() + '!' -- http://mail.python.org/mailman/listinfo/python-list