OSDir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] Slow down...


[Steven D'Aprano <steve at pearwood.info>]
> ...
> If we could look forward to 2028, when we're running Python 3.14 or so
> (4.7 if you prefer), how many fantastic language features that we cannot
> bear to give up would we be missing out on?

This, for just one:

    k = 6 if >!{myobj.meth(arg)[2]} elsenone 7 elsenan 8 else 5

Which is really annoying to write today, but would be much clearer
with binding expressions:

    if myobj is None:
        k = 7
    elif (t := myobj.meth) is None:
        k = 7
    elif (t := t(arg)) is None:
        k = 7
    elif (t := t[2]) is None:
        k = 7
    eiif math.isnan(t):
        k = 8
    elif t:
        k = 6
    else:
        k = 5

The future is blindingly bright :-)