subexpressions

Stef Mientki S.Mientki-nospam at mailbox.kun.nl
Sat Jun 2 10:16:17 CEST 2007


> 
> 
> Check the two alternatives:
> 
> def f(x):
>     y = x*x
>     return sin(y) + cos(y)
> 
> 44 key presses, including tabs and newlines and a blank line after the
> function, but excluding counting the shift key separately.
> 
> lambda x: (lambda y: sin(y) + cos(y))(x*x)
> 
> 42 key presses.
> 
> Apart from the extremely minor issue of "namespace pollution", I think
> that speaks for itself.

and now I've only 60 lines on my screen,
so what about

   def f(x): y = x*x; return sin(y)+cos(y);

cheers,
Stef Mientki



More information about the Python-list mailing list