On Tue, Oct 12, 2010 at 4:22 AM, Matti Airas <[email protected]> wrote: > On 12.10.2010 03:09, ext Lauro Moura wrote: >> >> What if we make objects with __str__ methods implicitly convertible to >> QString/QByteArray? Current this is not supported, as the following >> code fails: > > I believe this is the idea I presented a couple of months ago [1]. At the > time, Lizardo was quick to shoot it down (with good reasons). :-) > > [1] http://lists.openbossa.org/pipermail/pyside/2010-August/000927.html > >> from PySide.QtCore import * >> >> class Foo(object): >> def __str__(self): >> return '42' >> >> a = Foo() >> b = QObject() >> b.setObjectName(a) > > So, probably an explicit conversion is still preferable: > > b.setObjectName(str(a)) > > As mentioned in the previous discussion, explicit conversions conform to > standard Python conventions better than doing (potentially unexpected) > automatic conversions. > > Cheers, >
Good point. Anyway, another case of not digging the mailing list archives before asking. :) -- Lauro Moura INdT - Instituto Nokia de Tecnologia _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
