"in"consistency?

Nick Dumas drakonik at gmail.com
Mon Jul 7 17:30:41 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

[1,2] in [1,2,3] checks to see if the list [1,2] is an item in [1,2,3].
Because the list [1,2,3] only contains the integers 1,2,3, the code
returns a False. Try "[1,2] in [[1,2],[2,3]]"

David C. Ullrich wrote:
> Luckily I tried it before saying no, that's
> not how "in" works:
> 
>>>> 'ab' in 'abc'
> True
>>>> [1,2] in [1,2,3]
> False
> 
> Is there a reason for the inconsistency? I would
> have thought "in" would check for elements of a
> sequence, regardless of what sort of sequence it was...
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhyiwEACgkQLMI5fndAv9jbiwCeKMXrAclILJMPro5VuSRgdkvB
cGkAn1igcjFWRQJSwEDOxpk3spzceZGa
=iq8L
-----END PGP SIGNATURE-----



More information about the Python-list mailing list