[Python-ideas] if expensive_computation() as x:

Ethan Furman ethan at stoneleaf.us
Fri Feb 14 23:09:10 CET 2014


On 02/14/2014 02:02 PM, Terry Reedy wrote:
> On 2/14/2014 4:06 PM, Chris Angelico wrote:
>>
>> More to the point, excessive _and inappropriate_ indentation. An
>> if/elif/elif/elif/else chain puts all the conditions at the same
>> level, and all the bodies at the same level (one further in than the
>> conditions). The intention is that they're all peers,
>
> But they are *not* peers.
>
>> not that they're nested inside each other.
>
> But logically, they are.

Maybe `logic`ally, but not `human`ly.  ;)

For me at least, nested implies that to get to B, A has to be true: therefore B is inside A.

Otherwise it's simply a matter of prioritizing - LIFO, FIFO, random(), or whatever, and the only requirement to try the 
next is that the last did not meet our criteria.

--
~Ethan~


More information about the Python-ideas mailing list