undefined name error--the attribute named data doesn' even exist in memory until it is assigned within the setdata method as another way to appreciate how dynamic this model isconsider that we can change instance attributes in the class itselfby assigning to self in methodsor outside the classby assigning to an explicit instance objectx data "new valuex display(new value can get/set attributes outside the class too although less commonwe could even generate an entirely new attribute in the instance' namespace by assigning to its name outside the class' method functionsx anothername "spamcan set new attributes here toothis would attach new attribute called anothernamewhich may or may not be used by any of the class' methodsto the instance object classes usually create all of the instance' attributes by assignment to the self argumentbut they don' have to-programs can fetchchangeor create attributes on any objects to which they have references it usually doesn' make sense to add data that the class cannot useand it' possible to prevent this with extra "privacycode based on attribute access operator overloadingas we'll discuss later in this book (see and stillfree attribute access translates to less syntaxand there are cases where it' even useful--for examplein coding data records of the sort we'll see later in this classes are customized by inheritance let' move on to the second major distinction of classes besides serving as factories for generating multiple instance objectsclasses also allow us to make changes by introducing new components (called subclasses)instead of changing existing components in place as we've seeninstance objects generated from class inherit the class' attributes python also allows classes to inherit from other classesopening the door to coding hierarchies of classes that specialize behavior--by redefining attributes in subclasses that appear lower in the hierarchywe override the more general definitions of those attributes higher in the tree in effectthe further down the hierarchy we gothe more specific the software becomes heretoothere is no parallel with moduleswhose attributes live in singleflat namespace that is not as amenable to customization in pythoninstances inherit from classesand classes inherit from superclasses here are the key ideas behind the machinery of attribute inheritancesuperclasses are listed in parentheses in class header to make class inherit attributes from another classjust list the other class in parentheses in the new classes are customized by inheritance