class is compound statementwith body of statements typically indented appearing under the header in the headersuperclasses are listed in parentheses after the class nameseparated by commas listing more than one superclass leads to multiple inheritancewhich we'll discuss more formally in here is the statement' general formclass name(superclass)attr value def method(self)self attr value assign to name shared class data methods per-instance data within the class statementany assignments generate class attributesand specially named methods overload operatorsfor instancea function called __init__ is called at instance object construction timeif defined example as we've seenclasses are mostly just namespaces--that istools for defining names ( attributesthat export data and logic to clients class statement effectively defines namespace just as in module filethe statements nested in class statement body create its attributes when python executes class statement (not call to class)it runs all the statements in its bodyfrom top to bottom assignments that happen during this process create names in the class' local scopewhich become attributes in the associated class object because of thisclasses resemble both modules and functionslike functionsclass statements are local scopes where names created by nested assignments live like names in modulenames assigned in class statement become attributes in class object the main distinction for classes is that their namespaces are also the basis of inheritance in pythonreference attributes that are not found in class or instance object are fetched from other classes because class is compound statementany sort of statement can be nested inside its body--printassignmentsifdefand so on all the statements inside the class statement run when the class statement itself runs (not when the class is later called to make an instancetypicallyassignment statements inside the class statement make data attributesand nested defs make method attributes in generalthoughany type of name assignment at the top level of class statement creates same-named attribute of the resulting class object for exampleassignments of simple nonfunction objects to class attributes produce data attributesshared by all instances class coding details