FAQ

On Aug 18, 6:52?pm, "Jan Kaliszewski" wrote:
19-08-2009 o 00:24:20 markscottwright wrote:
What's the correct way to turn an iterator over bytes into a string?
This works, but, ewww:
? ? In [8]: "".join(iter("four score and seven years ago"))
? ? Out[8]: 'four score and seven years ago'
But it is the correct way (and even recommended over s=s+t or s+=t, when
applicable
-- see: ?http://docs.python.org/library/stdtypes.html#sequence-types-str-unico...).

Cheers,
*j

--
Jan Kaliszewski (zuo) <z... at chopin.edu.pl>
Thanks Jan (and all other responders). I suppose I shouldn't be
surprised - it's a known wart (http://wiki.python.org/moin/
PythonWarts), but it just looks so darn wrong. It is, as you point
out, much faster than "better looking" alternatives, though -
http://www.skymind.com/~ocrow/python_string/

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 6 of 8 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedAug 18, '09 at 10:24p
activeAug 20, '09 at 4:20a
posts8
users7
websitepython.org

People

Translate

site design / logo © 2022 Grokbase