[PySide] == operator not implemented

1,646 views
Skip to first unread message

Myles Jackson

unread,
Apr 14, 2011, 7:12:14 PM4/14/11
to pyside
Hey Guys,

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

Hugo Parente Lima

unread,
Apr 14, 2011, 8:20:10 PM4/14/11
to pys...@lists.pyside.org
On Thursday 14 April 2011 20:12:14 Myles Jackson wrote:
> Hey Guys,
>
> 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.

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

signature.asc

Myles Jackson

unread,
Apr 14, 2011, 9:51:02 PM4/14/11
to Hugo Parente Lima, pys...@lists.pyside.org
On 15/04/11 12:20, Hugo Parente Lima wrote:
> On Thursday 14 April 2011 20:12:14 Myles Jackson wrote:
>> Hey Guys,
>>
>> 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.
> 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 :-).

Awesome. thanks again.

Thomas Perl

unread,
Apr 15, 2011, 5:57:53 AM4/15/11
to Myles Jackson, pyside
Hi,

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/

Hugo Parente Lima

unread,
Apr 15, 2011, 4:35:24 PM4/15/11
to Myles Jackson, pys...@lists.pyside.org
On Thursday 14 April 2011 22:51:02 Myles Jackson wrote:
> On 15/04/11 12:20, Hugo Parente Lima wrote:
> > On Thursday 14 April 2011 20:12:14 Myles Jackson wrote:
> >> Hey Guys,
> >>
> >> 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.
> >
> > 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 :-).

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

--

signature.asc
Reply all
Reply to author
Forward
0 new messages