Generates a class attribute
class SharedData:
spam = 42 # generates a class attribute
x = SharedData() # make 2 instances
y = SharedData()
print x.spam, y.spam # they inherit and share spam
SharedData.spam = 99
print x.spam, y.spam, SharedData.spam
x.spam = 88
print x.spam, y.spam, SharedData.spam
Related examples in the same category