property and virtuality
Laszlo Zsolt Nagy
gandalf at geochemsource.com
Wed Mar 30 20:36:48 EST 2005
>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 which is better - lamba or
private functions. Lambda seems much
shorter but it is not as clear why it is there. :-)
>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 sure if descriptors
>allow changing their get/set/del methods). I'm not 100% sure if and how
>good that works (a quick hack would be easy, but to ship around the cliffs
>of multiple inheritance requires more careful navigation I fear...)
>
>
Yes, I feel the same. Using a metaclass could be a small help but rather
elaborate and probably much slower.
Thank you for your help.
--
_________________________________________________________________
Laszlo Nagy web: http://designasign.biz
IT Consultant mail: gandalf at geochemsource.com
Python forever!
More information about the Python-list
mailing list