"in"consistency?

Mel mwilson at the-wire.com
Mon Jul 7 20:41:20 EDT 2008


Ben Finney wrote:

> "David C. Ullrich" <dullrich at sprynet.com> writes:
> 
>> >>> 'ab' in 'abc'
>> True
>> >>> [1,2] in [1,2,3]
>> False
> 
> <URL:http://www.python.org/doc/ref/comparisons.html>
> 
>> Is there a reason for the inconsistency?
> 
> Probably. The special behaviour of string types was changed in Python
> 2.3, according to that document.

As it stands, you'd get  

[1,2] in [1,2,3] == False

[1,2] in [1, [1,2], 3] == True


This could be a good thing.

        Mel.
> 




More information about the Python-list mailing list