I've noticed when trying to compare certain QtCore classes (QPoint,
QRect, QLine) that the == operator has not been implemented.
Just wondering if this is intentional or an omission?
>>> p = PySide.QtCore.QPoint()
>>> p == None
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
NotImplementedError: operator not implemented.
p.s. PySide rocks.
_______________________________________________
PySide mailing list
PyS...@lists.pyside.org
http://lists.pyside.org/listinfo/pyside
The implementation exists, but it's wrong :-/
By default when no overload is found Shiboken throws an Python error instead
of just return false. It's a bug, but an easy one to solve :-).
>
> p.s. PySide rocks.
> _______________________________________________
> PySide mailing list
> PyS...@lists.pyside.org
> http://lists.pyside.org/listinfo/pyside
--
Hugo Parente Lima
INdT - Instituto Nokia de Tecnologia
Awesome. thanks again.
2011/4/15 Myles Jackson <mjac...@wetafx.co.nz>:
> I've noticed when trying to compare certain QtCore classes (QPoint, QRect,
> QLine) that the == operator has not been implemented.
>
> Just wondering if this is intentional or an omission?
>
>>>> p = PySide.QtCore.QPoint()
>>>> p == None
Ignoring the fact that this is a bug right now, PEP-8[1] says that you
should use the "is" operator when comparing to None:
- Comparisons to singletons like None should always be done with
'is' or 'is not', never the equality operators.
And this works already (using the Git master branch HEAD from PySide
and Shiboken):
>>> import PySide
>>> p = PySide.QtCore.QPoint()
>>> p is None
False
>>> p is not None
True
HTH.
Thomas
[1] http://www.python.org/dev/peps/pep-0008/
This was fixed in the following commit:
https://qt.gitorious.org/pyside/shiboken/commit/cf84217af1211b94a73bd60e8d1d5b7607b47d49
> Awesome. thanks again.
>
> >> p.s. PySide rocks.
> >> _______________________________________________
> >> PySide mailing list
> >> PyS...@lists.pyside.org
> >> http://lists.pyside.org/listinfo/pyside
--