Getting a dictionary from an object

Paolino paolo_veronelli at tiscali.it
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 :(
But:
 >>> class A(object):
...   def __getattr__(self,attr):
...     return 'whatever'
...
 >>> a=A()
 >>> a.b
'whatever'
 >>> getattr(a,'b')
'whatever'
 >>> 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 
attributes.


	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it



More information about the Python-list mailing list