PEP-308 a "simplicity-first" alternative

holger krekel pyth at
Wed Feb 12 05:28:16 CET 2003

Tony Lownds wrote:
> holger krekel <pyth at> wrote in message news:<mailman.1044992059.13191.python-list at>...
> >Inspired by "do the simplest thing that can possibly work"
> > i now think that 
> > 
> >         x and y else z
> > 
> > might just do it and avoid the need for a new construct.  
> > It's a very minor change just for fixing the problem at hand.  
> >
> For this to be a minor change "else" would have to be a binary
> operator:

no, this wouldn't work because

> x and y else z  <=>  (x and y) else z

the latter had no meaning.  and/else really just cures  the 

    x and y or z

idiom by expressing the intention that you want exactly one of
y or z and *don't* want to depend on the boolean value of y. 

> After (x and y) is evaluated, the value is false when either x is
> false, or when x is true and y is false. How is "else" meant to
> distinguish the two falses?

It would raise a Syntax error because you really need to say exactly

    ... and y else z

where "y" and "z" are expressions.


More information about the Python-list mailing list