Why are my queues empty even though there are items in it?

MRAB python at mrabarnett.plus.com
Tue Sep 20 21:43:18 CEST 2011


On 20/09/2011 20:09, Zero Piraeus wrote:
> :
>
> On 20 September 2011 14:42, MRAB<python at mrabarnett.plus.com>  wrote:
>> On 20/09/2011 19:13, Kayode Odeyemi wrote:
>>>
>>>      if item is not {} and timeout is not 0:
>>
>> `not {}` has the value True, so `item is not {}` means `item is True`.
>> The `is` checks for identity, not equality, so this is true only if `item`
>> actually has the value True or 1 (and this is an implementation-dependent
>> behaviour).
>
> Nitpick: "is not" is an operator:
>
>>>> "foo" is not {}
> True
>>>> "foo" is (not {})
> False
>
Oops! True.

However, it still doesn't do what the OP intended:

 >>> {} is {}
False
 >>> {} is not {}
True



More information about the Python-list mailing list