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

João Santos jmcs at jsantos.eu
Fri May 11 05:56:34 EDT 2018


Optimizing syntax for space makes sense for "mathematical" notation since
it's commonly written by hand, but putting space above readability in a
programming language design feels like a skewmorphism.

On Fri, 11 May 2018 at 11:41 Jacco van Dorp <j.van.dorp at deonet.nl> wrote:

> I dont really like "given".
>
> If we compare:
>
> if m given m = re.match(stuff):
>
> to
>
> 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
> verbose syntax.
>
> 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).
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180511/7858294a/attachment.html>


More information about the Python-ideas mailing list