A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/105695.html below:

using lambda to print everything in a list

using lambda to print everything in a list using lambda to print everything in a listRemco Gerlich scarblac at pino.selwerd.nl
Sun Apr 29 03:39:56 EDT 2001
Christian Tanzer <tanzer at swing.co.at> wrote in comp.lang.python:
> 
> "Alex Martelli" <aleaxit at yahoo.com> wrote:
> 
> > My personal impression is that lambda is a (minor)
> > nuisance.  Naming the code fragment that you want
> > to pass to some other function, by making it a
> > nested function, seems clearer & handier to me.
> 
> What about using `map' to apply a method to each element in a list?
> 
> Like in: 
> 
>     map (lambda s : s.capitalize (), l)
> 
> I wouldn't call a loop clearer in this case, despite the lambda.

That is debatable, but the list comprehension is fine:

      [ s.capitalize() for s in l ]

> For strings, one could of course pass `string.capitalize' to `map'.
> Unfortunately, this loop hole exists only for strings, and the powers
> that be plan on making the string module obsolete, anyway.

I really don't think they plan on that.

-- 
Remco Gerlich

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4