A trivial question about print

Alex Martelli aleax at aleax.it
Fri Apr 12 03:45:41 EDT 2002


Max M wrote:
        ...
>>>>>mystr(',').join(range(10),str)
>>>>
>> '0,1,2,3,4,5,6,7,8,9'
> 
> That sounds like a good idea!

I have my doubts that the BDFL wants to special-case the join method to 
save 5 characters over a map call:

        ','.join(map(str, range(10)))

(the saving kicking in only if the mystr(...) is not needed, of course).

Fewer and simpler "Lego Bricks" (TM) that fit together regularly, flexibly, 
and unsurprisingly, seem more Pythonic to me than "pre-fitted bricks" that
are necessarily more copious and each, individually, less flexible.  Since
pragmatism trumps purity, an idiom that's very pervasive (and that is
worth encouraging) AND awkward to express with "few simple bricks" will
sometimes get its own special-cased "pre-fitted brick".  However, it does
not appear to me that this case meets the requirements: this idiom is not
all that widespread, it's quite well expressed with existing tools, and
indeed existing tools have it all over the new proposal in terms of power
and flexibility (what if you want to call a function that takes two
parameters, for example -- map doesn't bat an eyelid, what would the
new proposed extension to the join method do?).

Personally, I'd rather see curry built-in -- it IS easy to write curry
in Python 2.2, but it's such a wonderful idiom (and would replace so
many lambda's;-) that I'd love to see it officially blessed.  Not that
I expect it to be (and nor will my heart be broken because of this:-).


Alex




More information about the Python-list mailing list