class property not working in python 2.5.1

utnapistim dan.barbus at gmail.com
Thu Feb 26 09:04:39 EST 2009


On Feb 26, 9:56 am, Christian Heimes <li... at cheimes.de> wrote:
> Dan Barbus schrieb:
>
> > Hi,
>
> > I have a problem with setting a property to a class instance, in
> > python 2.5.1. The property is defined through get and set methods, but
> > when I set it, the setter doesn't get called. Instead, I believe the
> > property in the instance gets replaced with a new object (string).
>
> > I have the following code (stripped down from my program):
>
> > class Model():
> >     def __init__(self, title = ''):
> >         self._views, self._title = [], None
> >         self.setTitle(title)
>
> *snip*
>
> Properties don't work correctly on old style classes. You have to
> subclass from object in order to get a new style class.
>
> class Model(object):
>     pass
>
> Christian

Thanks, that solved the problem.



More information about the Python-list mailing list