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

Devin Jeanpierre jeanpierreda at gmail.com
Wed Jul 18 20:31:19 CEST 2012


On Wed, Jul 18, 2012 at 2:16 PM, Masklinn <masklinn at masklinn.net> wrote:
>> It's both (with the caveat that, in Python, a character is just a
>> string of length 1).
>
> That's playing with words, especially comparing strings with Python 3
> binaries which *do* actually have a separate "character" type
> (reified to an integer).

No it isn't. Strings are adherents to the sequence protocol. The
Python datatype reference echoes what I said, nearly exactly.

http://docs.python.org/reference/datamodel.html#the-standard-type-hierarchy

> So Python strings don't have reified characters, a string's item and a
> slice of size 1 are essentially identical which is pretty much unique
> to them (as far as my knowledge of Python's sequences go).

Nothing about that feature makes them not-sequences; instead, it makes
them a rather special kind of sequence.

-- Devin



More information about the Python-ideas mailing list