[Python-ideas] Inline assignments using "given" clauses

Juancarlo Añez apalala at gmail.com
Sat May 12 20:27:53 EDT 2018

>     if (diff := x - x_base) and (g := gcd(diff, n)) > 1:
>          return g
I don't see the advantage in that succinctness:

g = special_gcd(x - x_base, n)

if g:

    return g

The code bases I work on constantly move towards having the next guy grok
what's going on just by reading the code.

It could also be:

if special_gcd(x - x_base, n) as g:

    return g


Juancarlo *Añez*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180512/bf3fca08/attachment.html>

More information about the Python-ideas mailing list