PEP308: Yet another syntax proposal

David Eppstein eppstein at
Mon Feb 10 20:16:54 CET 2003

On 2/10/03 7:36 PM +0100 holger krekel <pyth at> wrote:
>> My feeling is that the reason for short circuiting isn't so much because
>> of side effects (I think we should try to keep expressions as free of
>> side effects as possible) but because one or both of the two sides may
>> be undefined and raise an exception if the guard condition is not met.
> right.  in which case learning about and/or (which you have to anyway)
> often helps.  Because of the "y is false" problem in "x and y or z"
> there are some cases where it doesn't fit.  Do we have real code
> examples for them?

I posted one several hundred messages back:
   cols[i] if i >= 0 else None

It's from real code, an example where the and/or trick fails because you 
don't know the truth status of cols[i], and an example where the guard 
might serve to prevent an array out of bounds exception.
David Eppstein       UC Irvine Dept. of Information & Computer Science
eppstein at

More information about the Python-list mailing list