len(var) is [CONSTANT] equal to len(var) == [CONSTANT]?
Peter Otten
__peter__ at web.de
Thu Nov 23 06:03:39 EST 2006
Tor Erik Soenvisen wrote:
> (len(['']) is 1) == (len(['']) == 1) => True
>
> Is this the case for all numbers? I've tried running the following:
>
> for i in range(10000):
> for j in range(10000):
> if i != j:
> assert id(i) != id(j), 'i=%d, j=%d, id=%d' % (i,
> (i))
Shouldn't the test in the loop be
if i == j:
assert i is j
Of course it would fail...
Peter
More information about the Python-list
mailing list