A REALLY COOL PYTHON FEATURE:
m.faassen at vet.uu.nl
Thu May 11 13:56:59 CEST 2000
Courageous <jkraska1 at san.rr.com> wrote:
> While all the oldtimers here already know this, I thought
> I might share something really cool with some of my newbie
> peers.... :)
>>>> somenames = ["fred", "barney", "wilma", "betty"]
>>>> reallycool = reduce ( lambda x, y: x+", "+y, somenames )
> 'fred, barney, wilma, betty'
> Check that out. Do you know what a royal pain in the ass
> it is in most languages to do this? It's a godawful pain
> in the ass, let me tell you. And there it is, in all it's
> reduce ( lambda x, y: x+", "+y, somenames )
It's actually pretty easy in Python, too. :) (you think all this
reducing and lambda-ing is *easy*?)
string.join(["foo", "bar", "baz"], ", ")
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?
More information about the Python-list