[Python-ideas] Inline assignments using "given" clauses
Jacco van Dorp
j.van.dorp at deonet.nl
Fri May 11 05:40:51 EDT 2018
I dont really like "given".
If we compare:
if m given m = re.match(stuff):
if m := re.match(stuff)
then I count 4+(name_length) more tokens and 2 more spaces. Since I
believe := is perfectly clear, I don't see the reason for a far more
That all said, I would still prefer:
if re.match(stuff) as m:
which is exactly equal to the := in line length and parallels with.
While that may -technically- be a different beast.
For beginners the difference is really irrelevant, and you can just
tell advanced people the full story(technically speaking the as in a
with statement isn't an expression assignment, it's a part of the with
statement, and it feeds in the value through the context manager
machinery before binding it. Similar for the except statement.).
But I've kind of given up on "as" (so no need to reply on that bit).
More information about the Python-ideas