Laszlo Zsolt Nagy <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > My problem is about properties and the virtuality of the methods. I > would like to create a property whose get and set methods > are virtual. I had the same problems in Delphi before and the solution > was the same. I created a private _get method and a public > get method. The former one will call the latter. > [...] > I cannot override C2._getname instead, because c2.name would print > 'Test2" instead of lala. Clearly, the property stores a reference to the > get and set methods and it is not possible to have it use the new > methods. Creating a new property is the worst - need to duplicate code > and also C3.name is C1.name returns False. :-) It is not a big problem > because I found the solution just I wonder if there is a better way to > "virtualize" property get/set functions.
Alex Martelli has demonstrated the same technique to "fix" this disturbing property behavior during one of its talk at Pycon 2005: http://www.python.org/pycon/2005/papers/36/ (slides p.7&8) ... from this I infer that you found the best fix available ;) Regards, Sébastien -- http://mail.python.org/mailman/listinfo/python-list