spam shareddata( shareddata( spamy spam ( generates class data attribute make two instances they inherit and share 'spam( shareddata spamherebecause the name spam is assigned at the top level of class statementit is attached to the class and so will be shared by all instances we can change it by going through the class nameand we can refer to it through either instances or the class: shareddata spam spamy spamshareddata spam ( such class attributes can be used to manage information that spans all the instances- counter of the number of instances generatedfor example (we'll expand on this idea by example in nowwatch what happens if we assign the name spam through an instance instead of the classx spam spamy spamshareddata spam ( assignments to instance attributes create or change the names in the instancerather than in the shared class more generallyinheritance searches occur only on attribute referencesnot on assignmentassigning to an object' attribute always changes that objectand no other for exampley spam is looked up in the class by inheritancebut the assignment to spam attaches name to itself here' more comprehensive example of this behavior that stores the same name in two places suppose we run the following classclass mixednamesdata 'spamdef __init__(selfvalue)self data value def display(self)print(self datamixednames datadefine class assign class attr assign method name assign instance attr instance attrclass attr if you've used +you may recognize this as similar to the notion of ++' "staticdata members-members that are stored in the classindependent of instances in pythonit' nothing specialall class attributes are just names assigned in the class statementwhether they happen to reference functions ( ++' "methods"or something else ( ++' "members"in we'll also meet python static methods (akin to those in ++)which are just self-less functions that usually process class attributes unless the class has redefined the attribute assignment operation to do something unique with the __setattr__ operator overloading method (discussed in )or uses advanced attribute tools such as properties and descriptors (discussed in and much of this presents the normal casewhich suffices at this point in the bookbut as we'll see laterpython hooks allow programs to deviate from the norm often the class statement