[PyQt] pyqt behavior change
Linos
info at linos.es
Mon Aug 2 07:37:10 BST 2010
Ok, i have been using this format because it is more compact and a bit faster
but i will change my code, any other qt classes that have added lately a
__len__() method? From what version can i account this changes? Thanks for the info.
Regards,
Miguel Angel.
El 01/08/10 23:34, Phil Thompson escribió:
> 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