PEP-308 a "simplicity-first" alternative
Joshua Marshall
jmarshal at mathworks.com
Tue Feb 11 15:08:49 EST 2003
Nice. Gets my vote.
holger krekel <pyth at devel.trillke.net> wrote:
> I am still wondering if there is a simple way to fix the current
> ternary op "x and y or z". Everybody knows by now that
> this "fails" if y is a false value. Otherwise
> it works ok and is used in today's code everywhere.
> 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.
> It should be obvious what it does.
> if 'x' is true then 'y' is the result. Else 'y' is the
> result. So it doesn't matter if 'y' has a false value.
> Yes, it looks unusal but it is a simple "non-destructive"
> change which the people who now dislike PEP308 could
> probably live with.
> It has the positive side effect that explaining this
> ternary op variation goes hand in hand with explaining
> how and/or works in python. And it acknowledges the
> fact that we "almost" have a ternary op. Also it reads
> left to right and the alternatives "y else z"
> read well.
> regards,
> holger
More information about the Python-list
mailing list