Einstein summation notation

Ethan Furman ethan at stoneleaf.us
Wed Jul 22 21:21:04 CEST 2009


Paul Rubin wrote:
> Ethan Furman <ethan at stoneleaf.us> writes:
> 
>>Or if any(p for p in [header, body, footer, whatever, ...])
> 
> 
> No need for the genexp:
> 
>    if any([header, body, footer, whatever, ...])
> 
> But, you are using the built-in bool cast either way.

Right you are -- and

   if any([header, body, footer, whatever, ...])

sure looks nicer to me than your original code of

   if any(p != '' for p in [header, body, footer, otherthing1, ...])


But there a are a lot of decisions and factors to writing these things 
one way or the other.  I'm just glad Python supports the Something vs. 
Nothing model.

~Ethan~



More information about the Python-list mailing list