for class-based objectssearches for the attribute name in objectthen in all accessible classes above itusing the inheritance search procedure for nonclass objects such as modulesfetches from object directly as noted earlierthe preceding captures the normal and typical case these attribute rules can vary in classes that utilize more advanced toolsespecially for new-style classes --an option in and the standard in xwhich we'll explore in for examplereference inheritance can be richer than implied here when metaclasses are deployedand classes which leverage attribute management tools such as propertiesdescriptorsand __setattr__ can intercept and route attribute assignments arbitrarily in factsome inheritance is run on assignment tooto locate descriptors with __set__ method in new-style classessuch tools override the normal rules for both reference and assignment we'll explore attribute management tools in depth in and formalize inheritance and its use of descriptors in for nowmost readers should focus on the normal rules given herewhich cover most python application code the "zenof namespacesassignments classify names with distinct search procedures for qualified and unqualified namesand multiple lookup layers for bothit can sometimes be difficult to tell where name will wind up going in pythonthe place where you assign name is crucial--it fully determines the scope or object in which name will reside the file manynames py illustrates how this principle translates to code and summarizes the namespace ideas we have seen throughout this book (sans obscure special-case scopes like comprehensions)file manynames py global (modulename/attribute (xor manynames xdef ()print(xaccess global ( def () print(xclass cx def (self) self local (functionvariable (xhides module xclass attribute ( xlocal variable in method (xinstance attribute (instance xthis file assigns the same namexfive times--illustrativethough not exactly best practicebecause this name is assigned in five different locationsthoughall five xs in this program are completely different variables from top to bottomthe assignments to here generatea module attribute ( ) local variable in function ( ) class namespacesthe conclusion