Accessing class variables via instance
问题 In Python, class variables can be accessed via that class instance: >>> class A(object): ... x = 4 ... >>> a = A() >>> a.x 4 It's easy to show that a.x is really resolved to A.x , not copied to an instance during construction: >>> A.x = 5 >>> a.x 5 Despite the fact that this behavior is well known and widely used, I couldn't find any definitive documentation covering it. The closest I could find in Python docs was the section on classes: class MyClass: """A simple example class""" i = 12345