[PyQt] pyqt behavior change
Phil Thompson
phil at riverbankcomputing.com
Sun Aug 1 22:34:11 BST 2010
On Sun, 01 Aug 2010 19:49:11 +0200, Linos <info at linos.es> wrote:
> Hello,
> i don't know if this is a bug or an intended behavior but i am using in
> my
> machine Arch Linux pyqt 4.7.4 with sip 4.10.5 and in older versions the
> behavior
> was:
>
> combo = QComboBox()
> if combo:
> print "exists"
> else:
> print "is none"
>
> would print "exists" and now it prints "is none", i suppose it is a bug
> because
> the same test with QLabel still print "exists", i have not tested other
> classes
> though.
It's a side effect of an intended change that is triggering a bug in your
code.
QComboBox() now has a __len__() method which changes the behaviour of "if
combo".
If you want to test for None then you should always do so explicitly...
if combo is None:
print "is none"
else:
print "exists"
Phil
More information about the PyQt
mailing list