A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-September/104228.html below:

[Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's

[Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's [Python-Dev] issue2180 and using 'tokenize' with Python 3 'str's"Martin v. Löwis" martin at v.loewis.de
Wed Sep 29 01:22:28 CEST 2010
> I certainly wouldn't be opposed to an API that accepts a string as well
> though.

Notice that this can't really work for Python 2 source code (but of
course, it doesn't need to).

In Python 2, if you have a string literal in the source code, you need
to know the source encoding in order to get the bytes *back*. Now,
if you parse a Unicode string as source code, and it contains byte
string literals, you wouldn't know what encoding to apply.

Fortunately, Python 3 byte literals ban non-ASCII literal characters,
so assuming an ASCII-compatible encoding for the original source is
fairly safe.

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4