Python grab class in class definition.
- by epochwolf
I don't even know how to explain this, so here is the code I'm trying.
class Test:
type = self.__name__ #self doesn't work, how do I get a reference to Test?
class Test2(Test):
pass
#Test2.type should return "Test2"
The reason I'm even trying this is I'm working on creating a base class for an orm I'm using. I want to avoid defining the table name for every model I have. Also knowing what the limits of python is will help me avoid wasting time trying impossible things.