[PyQt] QPointF comparison is kinda wrong
    Florian Bruhin 
    me at the-compiler.org
       
    Tue Jun 30 12:26:28 BST 2015
    
    
  
* Arseniy Terekhin <senyai at gmail.com> [2015-06-30 13:38:38 +0300]:
> Windows 7, python 2.7.10, PYQT_VERSION_STR = '4.11.4'
> 
> >>> from PyQt4.QtCore import QPointF as p
> >>> p() < p()
> True
> >>> p() < p()
> False
> [...]
That's not anything specific to PyQt - it's just how Python 2
(unfortunately) implements comparing of incomparable types - it uses
their identity (id()) if they are of the same type:
    >>> class Foo(object): pass
    ...
    >>> Foo() < Foo()
    True
    >>> Foo() < Foo()
    True
    >>> Foo() < Foo()
    False
    >>> Foo() < Foo()
    True
    >>> Foo() < Foo()
    False
On Python 3, you get a much more sensible result:
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: unorderable types: QPointF() < QPointF()
Needless to say, I recommend switching to Python 3 ;)
Florian
-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20150630/855f164c/attachment.sig>
    
    
More information about the PyQt
mailing list