How to turn a string into a list of integers?

Steven D'Aprano steve+comp.lang.python at
Sun Sep 7 20:08:24 CEST 2014

Rustom Mody wrote:

> On Sunday, September 7, 2014 10:33:26 PM UTC+5:30, Steven D'Aprano wrote:
>> MRAB wrote:
>> > I don't think you should be saying that it stores the string in Latin-1
>> > or UTF-16 because that might suggest that they are encoded. They
>> > aren't.
>> Of course they are encoded. Memory consists of bytes, not Unicode code
>> points, [...]

> Dunno about philosophical questions -- especially unicode :-)
> What I can see (python 3) which is I guess what MRAB was pointing out:
>>>> "".encode
> <built-in method encode of str object at 0x7f3955da3848>
>>>> "".decode
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: 'str' object has no attribute 'decode'

What's your point? I'm talking about the implementation of how strings are
stored in memory, not what methods the str class provides.


More information about the Python-list mailing list