Re: property and virtuality

2005-04-03 Thread Greg Ewing
Laszlo Zsolt Nagy wrote: 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. You might find the following function useful, which I developed for use in PyGUI. def overridable_property(name, doc = None): ""

Re: property and virtuality

2005-04-01 Thread Michele Simionato
Diez B. Roggisch: > On second thoughts, a metaclass _might_ help here - but it would be rather > elaborate: look in the baseclasses for properties that have getters and > setters of the same name as some methods in the current class, and replace > them, or create a new property with them (I'm not

Re: property and virtuality

2005-04-01 Thread boisgera
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

Re: property and virtuality

2005-04-01 Thread Terry Reedy
"harold fellermann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I asked this question some time ago, but as I got no answer, so I just > try it a second time. This did get out, but I can't answer except to suggest looking at code for other C extension modules. Nested (inner)

Re: property and virtuality

2005-04-01 Thread harold fellermann
Hello, I asked this question some time ago, but as I got no answer, so I just try it a second time. I am working on a C extension module that implements a bunch of classes. Everything works fine so far, but I cannot find any way to implement class attributes or inner classes. Consider you have

Re: property and virtuality

2005-03-31 Thread Steven Bethard
Steven Bethard wrote: Laszlo Zsolt Nagy wrote: 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. Perhaps you want to roll your own VirtualProperty descriptor? Here's one based off the property implementation

Re: property and virtuality

2005-03-31 Thread Steven Bethard
Laszlo Zsolt Nagy wrote: 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. Perhaps you want to roll your own VirtualProperty descriptor? Here's one based off the property implementation in Raymond Hettinger'

Re: property and virtuality

2005-03-31 Thread Michele Simionato
I think you may find Alex Martelli's PyCon slides somewhere on the net. The black magic slides discuss this issue. But I think the fix he suggests is not dissimilar from what you are already doing. I don't remember exactly now, but it is always worth a look. Michele Simionato -- http:

Re: property and virtuality

2005-03-31 Thread Diez B. Roggisch
> Great. I'll think about this and decide which is better - lamba or > private functions. Lambda seems much > shorter but it is not as clear why it is there. :-) I did put comments above each property line - so one might argue that's about the same effort as writing the method explicit. Alternativ

Re: property and virtuality

2005-03-31 Thread Laszlo Zsolt Nagy
I'm not aware of possibility that works as you first expected. You yourself explained why. But _maybe_ you can use lambda here - that creates the layer of indirection one needs. foo = property(lambda self: self.get_foo(), lamda self,v: self.set_foo(v)) Great. I'll think about this and decide w

Re: property and virtuality

2005-03-31 Thread Diez B. Roggisch
> 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

property and virtuality

2005-03-31 Thread Laszlo Zsolt Nagy
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