Understanding properties
Alex Martelli
aleax at aleax.it
Sat Jul 6 13:35:48 EDT 2002
merman wrote:
>> class MyObject(object):
>
> Why it needs the inheritance from object - I don't understand.
Backwards compatibility. To be precise, a class using properties
needs to be new-style -- subclassing object is the simplest way
to achieve this (there are quite a few others) -- because by
default a class is a "classic" one, implementing exactly the
same semantics as in Python 2.1 and older, ensuring no major code
breakage in porting from 2.1 to 2.2 but constraining the applicability
of the new features to classic classes.
Alex
More information about the Python-list
mailing list