Getting a dictionary from an object

Paolino paolo_veronelli at
Sat Jul 23 15:12:31 CEST 2005

Thanos Tsouanas wrote:
> On Sat, Jul 23, 2005 at 12:06:57PM +0200, Paolino wrote:
>>use getattr(self.obj,key) possibly, as __getattribute__ gets total 
>>control on attribute access
> Thanks, but what do you mean by 'total control'?
Probably nothing to do with your question :(
 >>> class A(object):
...   def __getattr__(self,attr):
...     return 'whatever'
 >>> a=A()
 >>> a.b
 >>> getattr(a,'b')
 >>> a.__getattribute__('b')
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
AttributeError: 'A' object has no attribute 'b'

This can probably touch you if your objects uses defualt searching for 


Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB

More information about the Python-list mailing list