elseself __dict__[namevalue powers( print( squareprint( cubex square print( squareor use object * * * the final optioncoding this with __getattribute__is similar to the prior version because we catch every attribute nowthoughwe must also route base value fetches to superclass to avoid looping or extra calls--fetching self _square directly works toobut runs second __getattribute__ callsamebut with generic __getattribute__ all attribute interception class powers(object)def __init__(selfsquarecube)self _square square self _cube cube need (objectin only def __getattribute__(selfname)if name ='square'return object __getattribute__(self'_square'* elif name ='cube'return object __getattribute__(self'_cube'* elsereturn object __getattribute__(selfnamedef __setattr__(selfnamevalue)if name ='square'object __setattr__(self'_square'valueelseobject __setattr__(selfname valuex powers( print( squareprint( cubex square print( squareor use __dict__ * * * as you can seeeach technique takes different form in codebut all four produce the same result when run for more on how these alternatives compareand other coding optionsstay tuned for more realistic application of them in the attribute validation example in the section "exampleattribute validationson page firstthoughwe need to take short side trip to study new-style-class pitfall associated with two of these tools--the generic attribute interceptors presented in this section managed attributes