our next new-style extension is properties-- mechanism that provides another way for new-style classes to define methods called automatically for access or assignment to instance attributes this feature is similar to properties ( "gettersand "setters"in languages like java and #but in python is generally best used sparinglyas way to add accessors to attributes after the fact as needs evolve and warrant where neededthoughproperties allow attribute values to be computed dynamically without requiring method calls at the point of access though properties cannot support generic attribute routing goalsat least for specific attributes they are an alternative to some traditional uses of the __getattr__ and __setattr__ overloading methods we first studied in properties have similar effect to these two methodsbut by contrast incur an extra method call only for accesses to names that require dynamic computation--other nonproperty names are accessed normally with no extra calls although __getattr__ is invoked only for undefined namesthe __setattr__ method is instead called for assignment to every attribute properties and slots are related toobut serve different goals both implement instance attributes that are not physically stored in instance namespace dictionaries-- sort of "virtualattribute--and both are based on the notion of class-level attribute descriptors in contrastslots manage instance storagewhile properties intercept access and compute values arbitrarily because their underlying descriptor implementation tool is too advanced for us to cover hereproperties and descriptors both get full treatment in property basics as brief introductionthougha property is type of object assigned to class attribute name you generate property by calling the property built-in functionpassing in up to three accessor methods--handlers for getsetand delete operations--as well as an optional docstring for the property if any argument is passed as none or omittedthat operation is not supported the resulting property object is typically assigned to name at the top level of class statement ( name=property())and special syntax we'll meet later is available to automate this step when thus assignedlater accesses to the class property name itself as an object attribute ( obj nameare automatically routed to one of the accessor methods passed into the property call for examplewe've seen how the __getattr__ operator overloading method allows classes to intercept undefined attribute references in both classic and new-style classesclass operatorsdef __getattr__(selfname)if name ='age'return else advanced class topics