I was reading this answer to the question What are metaclasses in Python? when I learned that classes in Python don’t have to be created using the class
keyword. This made me wonder: what exactly is a class?
Most discussions about Python classes that I recall having read seem to assume a common understanding of what they are, or at best provide descriptions rather than definitions. I think what I want know is this:
Suppose I’m going to give you an object X and ask whether it’s a class or not. Yes or no. You need to come up with a test before seeing X. (You are not allowed to see X first and then devise a test after having seen it.)
I suppose this test would be equivalent to a definition of classes. Is there such a test/definition?