[Python-Dev] len(chr(i)) = 2? (original) (raw)
Greg Ewing greg.ewing at canterbury.ac.nz
Thu Nov 25 04:19:33 CET 2010
- Previous message: [Python-Dev] len(chr(i)) = 2?
- Next message: [Python-Dev] [Preview] Comments and change proposals on documentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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:
Make things so that 'for c in string' does actually iterate over characters rather than code units. This could break existing code, though.
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
- Previous message: [Python-Dev] len(chr(i)) = 2?
- Next message: [Python-Dev] [Preview] Comments and change proposals on documentation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]