[Python-ideas] '' in 'abc' == True

Masklinn masklinn at masklinn.net
Wed Jul 18 19:43:27 CEST 2012


On 2012-07-18, at 19:30 , anatoly techtonik wrote:

> I've just spotted inconsistency between string and lists handling:
> 
>>>> '' in 'abc'
> True
>>>> '' in 'abc'.split()
> False
>>>> [] in ['a', 'b', 'c']
> False
> 
> Why strings here behave differently than other sequence types? Is that
> by design?

Erm… yes? `in` would not be very useful for strings if you could only use
it to check for a single character would it?


More information about the Python-ideas mailing list