[PySide] Shiboken-generated __nonzero__() methods and truth value testing
John Tourtellott
john.turtle at gmail.com
Sun Sep 22 22:46:48 CEST 2013
I am using Shiboken to wrap a small class library. In my typesystem.xml
file, I have added a __nonzero__() method to some of the classes using the
<add-function> element. The method gets generated OK and I can call it from
python, however, python is *not* calling the Shiboken-generated
__nonzero__() method when doing truth value testing, for example, in an "if
object:" expression.
Looking briefly at the Shiboken source, in particular,
CppGenerator::hasBoolCast(), I get the impression that I *must* use the
--use-isnull-as-nb_nonzero command-line option in order to get the expected
boolean value. My tests further indicate that this option only applies to
isNull() methods that are implemented in the C++ classes, not added via the
typesystem file. Is this correct?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20130922/bcc823df/attachment.html>
More information about the PySide
mailing list