On Fri, Nov 7, 2008 at 11:24 AM, Georg Altmann <[EMAIL PROTECTED]> wrote: > Hello, > > I am thinking about wether I should use python properties in my code. As > PyQt is currently following Qt style (getter: property(), setter: > getProperty()), I am a bit undecided. > > Benefits of python properties from my point of view: > > 1. Code is more expressive (readability). > > Drawbacks: > > 1. Classes derived from Qt classes mix python and Qt property style > (inconsistent).
I use python properties anyway -- I don't think it matters particularly unless you're aiming to look as much like the Qt API as possible (providing a PyQt-based library, for example). Is PyQt5 going to use Python properties like other bindings do? > > 2. One more design decision to worry about: Is this a methos or is it a > (readonly) property? You also have to remember this in the client code. I'm not sure this is a real problem. It's a reasonably clear distinction. I can't find the exact Python mailing list post, but generally the Python 3.0 API is going to use properties where it makes sense to do so -- one hard and fast rule that was mentioned was to use it where the code runs in constant time. > 3. Python properties do not natively support getter/setter overriding in > subclasses. > (I know there are ways around this, but I'd rather stick with what standard > python provides.) > > 4. Bloats class definition (extra line for property()). Qt also declares its properties (using the Q_PROPERTY macro). > > What do you think? > > Regards > Georg > > _______________________________________________ > PyQt mailing list [email protected] > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
