[Tutor] Problem appending to a list using a property within a class

John Fouhy john at fouhy.net
Wed Nov 9 05:09:05 CET 2005

On 09/11/05, Roy Bleasdale <royb at ubiquity.com.au> wrote:
> I have created a List within a class. If I try and append to the list using
> the set function using the property value my variable stops being a list.
> Can anyone explain why the set function called by the class property does
> not append to the list?
> Here is some sample code:
> class ShoppingBag:

Properties only work properly with new style classes.  You get a new
style class by inheriting from another new style class, or by
inheriting from object.

Try changing the first line to "class ShoppingBag(object):".

This is a somewhat annoying distinction that will hopefully go away in
a future version of python (when all classes become new style).


More information about the Tutor mailing list