[FRPythoneers] iterator like inject:into to generating comma-separated list

jason songhurst jason.songhurst at valtech.com
Mon Sep 16 20:14:48 MDT 2002

Sean Reifschneider wrote:
> On Mon, Sep 16, 2002 at 07:25:25PM -0500, Cameron Laird wrote:
>>I prefer
>> string.join(map(str, list), ",") 
> Sure, but which one is the One True Way (tm)?  ;-)
> Sean

Guido van Rossum, the BDFL, wrote in 1996:
   Opinions on ugliness can vary, but personally, I just wish I'd never
   given in to the pressure to add lambda in the first place.

And even recently the BDFL called lambda a 'failed experiment'.
   see: http://www.python.org/doc/essays/ppt/oscon2002/

But Fredric Lundh, someone who must be passing familiar with the One 
True Way (Python version) (tm), wrote about using lambdas:
   If you like lambdas, use them.  All the best pythoneers do, so why
   shouldn't you?

I have found that after using Scheme, lambdas in Python seem awkward. 
Of course that situation is better with the advent of nested scopes, but 
the syntax makes lambdas usually look clunky compared to the rest of Python.


However, from the docstring in string.py:
   Warning: most of the code you see here isn't normally used nowadays.

   With Python 1.6, many of these functions are implemented as methods
   on the standard string object.

So the 'string.join(words, sep)', is not the One True Way (tm).  But I 
think it is very close...


Why not try something which is clear, consise, object-oriented, 
applicative (to satisfy the lambda deep within us all), and modern:
   ",".join(map(str, list))

or use lambda. <grin>

- jason

More information about the FRPythoneers mailing list