Re: How to customize getattr(obj, prop) function ?

2006-05-17 Thread Richard Copeland
Try this: class Class: a='aa' b='bb' def __getattr__(self, ppt): return 'custom computed result' __getattr__ is only called when "normal" attribute lookup fails, so there's no need for the "hasattr" test. Also, I believe that __getattribute__ only applies to new-style c

Re: How to customize getattr(obj, prop) function ?

2006-05-17 Thread Richard Copeland
Try this: class Class: a='aa' b='bb' def __getattr__(self, ppt): return 'custom computed result' __getattr__ is only called when "normal" attribute lookup fails, so there's no need for the "hasattr" test. Also, I believe that __getattribute__ only applies to new-style cla

Re: How to customize getattr(obj, prop) function ?

2006-05-17 Thread Richard Copeland
Try this: class Class: a='aa' b='bb' def __getattr__(self, ppt): return 'custom computed result' __getattr__ is only called when "normal" attribute lookup fails, so there's no need for the "hasattr" test. Also, I believe that __getattribute__ only applies to new-style cl

Re: How to customize getattr(obj, prop) function ?

2006-05-17 Thread Richard Copeland
I tested the exact code I sent you on python 2.4.1. What version of Python are you using? Thanks, Rick Pierre wrote: > Nop I get the same AttributeError when I try to access to the property > "c"... > -- http://mail.python.org/mailman/listinfo/python-list

Re: How to customize getattr(obj, prop) function ?

2006-05-17 Thread Richard Copeland
I tested the exact code I sent you on python 2.4.1. What version of Python are you using? Thanks, Rick Pierre wrote: > Nop I get the same AttributeError when I try to access to the property > "c"... > -- http://mail.python.org/mailman/listinfo/python-list