PEP-308 a "simplicity-first" alternative

Terry Reedy tjreedy at
Thu Feb 13 00:45:20 CET 2003

"Bengt Richter" <bokr at> wrote in message
news:b2ecou$659$0 at
> Whoops, I think I had another idea:
> The old short circuiting "c and x or y" could also work if we had a
> that said "treat this as true without changing its value even though
it might be false".
> E.g., suppose {x} meant treat x as true in the context of a logical
expression. Then,
>     c and {x} or y
> or maybe for style's sake
>     c and {x} or {y}
> would do it. There's no confusion with a dict literal, since there's
no bare
> ':' inside. (I.e., {x[1:2]} would be ok and the expression
>     c and {x[1:2]} or 'x'
> could have the value [] e.g. if x==[0]

Very interesting.  One implementation would be to add an internal
truth-wrapper object and modify 'or' to unwrap it's return value if
the return value is a truth wrapper.  It could perhaps be done more
simply than that.  This goes on my list of acceptable-till-shot-down
fixes.  (The arrow stuff didn't ;-)

> Since this is my idea, of course I like it best ;-)

Congrats.  This is just the sort of minimal fix I was also trying to
think of.

Terry J. Reedy

More information about the Python-list mailing list