deferred decorator

Bryan belred1 at yahoo.com
Wed Dec 8 03:13:48 CET 2004


i was intrigued with a recently posted cookbook recipe which implements deferred 
results with decorators:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/355651

the problem i see with this recipe is that the author only tested his code by 
printing the values which causes __getattr__ to be called with '__str__' and 
work correctly.  but, if you were to remove the print statements and just do a v 
+ v, __getattr__ won't get called as he expected and the join will never happen. 
   i think by making __coerce__ as smart as __getattr__ this recipe would work. 
  can someone validate that i'm correct in what i'm saying?

i'm also curious if it's possible to write this recipe using the new class style 
for the Deffered class.    it appears you can nolonger delegate all attributes 
including special methods to the contained object by using the __getattr__ or 
the new __getattribute__ methods.  does anyone know how to port this recipe to 
the new class style?

thanks,

bryan



More information about the Python-list mailing list