Avoiding local variable declarations?

dpapathanasiou denis.papathanasiou at gmail.com
Thu Nov 13 15:49:02 EST 2008


>     return chr( random.randrange(0, 26) + (97 if random.randrange(0,
> 100) > 50 else 65)

> or
>
>     return chr( random.randrange(0, 26) + [26,97][random.randrange(0,
> 100) > 50]

Ah, thanks, these are the syntax examples I was looking for.

> but what's wrong with you original code?

I come from a functional programming school of thought, where you
avoid local variable declarations if at all possible.



More information about the Python-list mailing list