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-November/105991.html below:

[Python-Dev] len(chr(i)) = 2?

[Python-Dev] len(chr(i)) = 2? [Python-Dev] len(chr(i)) = 2?Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 25 04:19:33 CET 2010
On 25/11/10 06:37, Alexander Belopolsky wrote:

> I don't think there is a recipe on how to fix legacy
> character-by-character processing loop such as
>
>     for c in string:
>        ...
>
> to make it iterate over code points consistently in wide and narrow
> builds.

A couple of possibilities:

1) Make things so that 'for c in string' does actually
iterate over characters rather than code units. This could
break existing code, though.

2) Provide some things like

    for c in string.chars():
      ...

    for c in string.graphemes():
      ...

where chars() and graphemes() return appropriate iterators.
(Or possibly iterable views, but that would raise the
expectation that the views could also be randomly indexed
by char or grapheme, which we probably wouldn't want to
support.)

-- 
Greg
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