assignments in some contexts-- tradeoff described in and mentioned in the context of the case study example we'll explore at the end of this avoiding loops in attribute interception methods these methods are generally straightforward to usetheir only substantially complex aspect is the potential for looping ( recursingbecause __getattr__ is called for undefined attributes onlyit can freely fetch other attributes within its own code howeverbecause __getattribute__ and __setattr__ are run for all attributestheir code needs to be careful when accessing other attributes to avoid calling themselves again and triggering recursive loop for exampleanother attribute fetch run inside __getattribute__ method' code will trigger __getattribute__ againand the code will usually loop until memory is exhausteddef __getattribute__(selfname) self other loopstechnicallythis method is even more loop-prone than this may imply-- self attribute reference run anywhere in class that defines this method will trigger __getattri bute__and also has the potential to loop depending on the class' logic this is normally desired behavior--intercepting every attribute fetch is this method' purposeafter all--but you should be aware that this method catches all attribute fetches wherever they are coded when coded within __getattribute__ itselfthis almost always causes loop to avoid this looproute the fetch through higher superclass instead to skip this level' version--because the object class is always new-style superclassit serves well in this roledef __getattribute__(selfname) object __getattribute__(self'other'force higher to avoid me for __setattr__the situation is similaras summarized in --assigning any attribute inside this method triggers __setattr__ again and may create similar loopdef __setattr__(selfnamevalue)self other value recurs (and might loop!here tooself attribute assignments anywhere in class defining this method trigger __setattr__ as wellthough the potential for looping is much stronger when they show up in __setattr__ itself to work around this problemyou can assign the attribute as key in the instance' __dict__ namespace dictionary instead this avoids direct attribute assignmentdef __setattr__(selfnamevalue)self __dict__['other'value managed attributes use attr dict to avoid me