Base Nordwind

"7.81% more interesting than the news"

Home     Programming     About      
Python Class Attributes
 

If you are used to C-like languages (c++,c#,java…), you will find that classes in Python are a bit of a different beast. Classes are completely optional in Python, especially if you are just writing a quick script, however they are still an essential part of OOP.

In Python instances of a class reference the (static) class itself rather than creating complete new instances of the class. This has the effect of sharing any attributes defined in the class in such a way that changing a class attribute changes it for every instance of the class.

For a heavily commented example of this, see below.