Detect if class was defined declarative or functional - possible?
问题 Here's a simple class created declaratively: class Person: def say_hello(self): print("hello") And here's a similar class, but it was defined by invoking the metaclass manually: def say_hello(self): print("sayolala") say_hello.__qualname__ = 'Person.say_hello' TalentedPerson = type('Person', (), {'say_hello': say_hello}) I'm interested to know whether they are indistinguishable. Is it possible to detect such a difference from the class object itself? >>> def was_defined_declaratively(cls): ..