For review: PEP 308 - If-then-else expression

Bengt Richter bokr at oz.net
Tue Feb 11 02:00:04 EST 2003


On Mon, 10 Feb 2003 12:07:41 -0800, "James J. Besemer" <jb at cascade-sys.com> wrote:
[...]
>
>     targetVar1 = ( condition1
>                      ? ( condition2
>                          ? result1
>                          : result2 )
>                      : result3 )
>
I am currently proposing a multi-condition expression whose ternary form would be spelled

      targetVar1 = ( condition1
                       -> ( condition2
                            -> result1
                            -> result2 )
                       -> result3 )

or alternatively

      targetVar1 = condition1 -> ( condition2 -> result1 -> result2 ) -> result3

The full deal is
    c1 -> v1 >< c2 -> v2 >< c3 -> v3 >< True -> vdefault >!< Exception1 -> ev1 >!< E2 -> ev2

but ">< True" is optional as a tail condition spec, resulting in the simple
    c -> vTrue -> vFalse ternary

Regards,
Bengt Richter




More information about the Python-list mailing list