I hate all of you guys. :) (Lauro, -0.5!?) But I'm convinced, no dynamic Qt properties using the constructor.
On 13 August 2010 08:37, Lauro Moura <[email protected]> wrote: > On Fri, Aug 13, 2010 at 5:01 AM, Mark Summerfield <[email protected]> wrote: >> On Thu, 12 Aug 2010 17:37:12 -0300 >> Marcelo Lira <[email protected]> wrote: >>> According to PSEP 101[1] a constructor for QObject and derived classes >>> should be able to set Qt properties through named arguments. >>> In practical terms to set the Qt property "objectName" to "foobar" one >>> should do: >>> >>> obj = QObject(objectName='foobar') >>> >>> This can be done in a more verbose way: >>> >>> obj = QObject() >>> obj.setProperty('objectName', 'foobar') >>> >>> You can set dynamic properties, i.e. not previously declared on the >>> QObject derived object: >>> >>> obj = QObject() >>> obj.setProperty('myNumber', 123) >> >> [snip] >> >> I agree with Matti that this should be a separate PEP if you plan to >> pursue it. >> >> As I understand it you want to allow: >> >> obj = QObject(my_new_property="Hello") >> >> on the basis that the user can do this at any time: >> >> obj.setProperty("my_new_property", "Hello") >> >> I am opposed to this. >> >> At the moment only existing properties can be set in the constructor, >> which means that typos and other errors result in an exception which I >> think is good. >> >> This means that if someone wants to add a new property they must use >> QObject.setProperty(), in other words they must do so explicitly, which >> I think is a good thing. >> >> -1 >> > > Until yesterday I was agreeing with this change but after thinking > better, I believe that leaving the constructor accepting only already > existing properties would be cleaner/better. Somewhat like this pure > python example: > > class Bacon: > def __init__(self, myprop=0, myotherprop='eggs'): > self.myprop = myprop > self.myotherprop = myotherprop > > And to set the dynamic ones, use the "setattr" function. Setting > dynamic ones in the constructor would endup using **kwargs magic. > > So, -0.5. > > -- > Lauro Moura > INdT - Instituto Nokia de Tecnologia > -- Marcelo Lira dos Santos INdT - Instituto Nokia de Tecnologia _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
