setting a property via self.__dict__

Aahz aahz at
Thu Oct 31 06:09:36 CET 2002

In article <efa417af.0210301251.2b380da at>,
Frank von Delft <fvondelft at> wrote:
>Um...  after some mulling:  so what is the advantage of having the
>property in the class dictionary?  Because I realised it's quite happy
>in the instance dictionary, like such:
>>>> class A(object):
>	def __init__(self,**kwargs):
>		self.a = property(self._getA,self._setA)
>		self.__dict__.update(**kwargs)
>	def _getA(self): 
>		return self._a
>	def _setA(self,a):
>		self._a = a
>Really I should ask:  why do all the examples show it defined in the
>class dictionary?

Because new-style classes don't do magic method lookups in class
instances.  Guido considered the ability to do that with classic classes
a wart and "fixed" it.
Aahz (aahz at           <*>

Project Vote Smart:

More information about the Python-list mailing list