Using property in classic class may not work

Alex Martelli aleax at aleax.it
Tue Apr 15 16:40:13 CEST 2003


A. Lloyd Flanagan wrote:

> Alex Martelli <aleax at aleax.it> wrote in message
> news:<ifPma.15344$LB6.409776 at news1.tin.it>...
>> Neil Hodgson wrote:
>> 
>> >     The class in question is derived from a wxWindows class, so I can't
>> > make it derive just from object. The "What's New in Python 2.2"
>> > document only mentions property wrt new-style clases. Can I depend on
>> > property working for classic classes? Is there a workaround such as
>> > deriving from object as well?
>> 
>> No, and yes, respectively -- deriving from object means your class
>> isn't classic any more, so properties do work as intended there.  Vide:
>> 
> ... (big chunck cut) ...
>> as you see, this does work as intended.
>> 
>> 
>> Alex
> 
> However, the last time I tried to subclass from both wxFrame and
> object, wxPython freaked out (that's a technical term for "I don't
> remember what happened, but boy, it sure didn't work").
> Not sure about the latest version of wxPython, though -- there's
> binaries for python 2.3 out by now.  I'll have to try it again..

If wxPython keeps freaking, you may have to give up on properties
if you HAVE to inherit its classes (can't just wrap with automatic
delegation) and go back to "good old" (yeah right) __setattr__.  Or,
gently pressure wxPython's maintainers to have them move to
new-style classes... whatever aspects of old-style classes they
may be taking for granted at present, migrating to new-style can
hardly be a major job, in my experience.


Alex





More information about the Python-list mailing list