lambda question

Max M maxm at mxm.dk
Wed Mar 12 02:57:02 EST 2003


Andrew Koenig wrote:

> I must confess that
> 
>         title = lambda s: "<title> % </title>" % s
> 
> doesn't strike me as being any simpler than
> 
>         def title(s): return "<title> % </title>" % s
> 
> which, in turn, I find slightly less readable than
> 
>         def title(s):
>             return "<title> % </title>" % s


One could even argue that it is even more readable to skip the lambda 
alltogether:

     s = 'The Title'
     title_tag = '<title> %s </title>'
     print title_tag % s

     >>> <title> The Title </title>

If it is simple enough to put into a lambda, it is probably simple 
enough to just use string substitution directly.

-- 

hilsen/regards Max M Rasmussen, Denmark

http://www.futureport.dk/
Fremtiden, videnskab, skeptiscisme og transhumanisme





More information about the Python-list mailing list