def get_class_name():
    f = sys._getframe(1)
try:
    class_name = f.f_locals['self'].__class__.__name__
except KeyError:
    class_name = None
return class_name
Python: How to retrieve class information from a 'frame' object?