How do I convert an iterator over bytes into a str?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Thu Aug 20 06:20:09 CEST 2009


On Wed, 19 Aug 2009 20:04:12 -0700, alex23 wrote:

> markscottwright <markscottwri... at gmail.com> wrote:
>> 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.
> 
> Don't forget that it's exceptionally easy to create your own mechanism
> for doing this:
> 
>   def join(seq, sep):
>      return sep.join(map(str, seq))

Oh oh oh my brain hurts!!! Neither "seq" nor "sep" are real words, both 
are abbreviations, they differ by a single letter, and the two letters 
are mirror images of each other!!!

This is a recipe for confusion when people get the order of sep and seq 
mixed up. Hopefully in real life code, you'd use a less easily confused 
function signature -- even just spelling out sequence and separator in 
full would reduce confusion to essentially zero.



-- 
Steven



More information about the Python-list mailing list