#75 posted on Wed Mar 24 00:00:00 2010
Python classes are objects
Python just keeps on surprising me with it's versatility and simple, but powerful, architecture. I just learnt yesterday that Python classes can be used as objects as soon as they are defined. You don't actually need to create an instance of it.
So, consider the following simple class;Now you can use the variable class MyClass:
x = 1x in the class even before any instances have been created from the class. So the following works;See the official Python documentation for classes here ("As in Smalltalk, classes themselves are objects.").print MyClass.x












Comments (post a comment)