Property confusion

Alex Martelli aleaxit at yahoo.com
Wed Sep 8 05:30:38 EDT 2004


kepes.krisztian <kepes.krisztian at peto.hu> wrote:
   ...
> class A:
   ...
>       GS=property(g,s)

> If I not use object, the GS is used as member, not property.

It's BOUND as an instance attribute, after which that takes precedence.
Only newstyle classes can fully support the new descriptors; classic
classes cannot, that would break backwards compatibility.

Always use newstyle classes unless you specifically need to support
legacy code.  Handiest way may be to always start your modules with

__metaclass__ = type

This makes all parents-less classes newstyle by default.  Without this
global, a parent-less class must be oldstyle by default, to keep full
backwards compatibility with Python as it was 3+ years ago.


Alex



More information about the Python-list mailing list