[Python-Dev] Call for prudence about PEP-572 (original) (raw)

David Mertz mertz at gnosis.cx
Sun Jul 8 13:24:40 EDT 2018


The case I find more reasonable is assignment in earlier arguments:

z = something () w = myfun(x := get_data(), y=calculate(x, z))

I would probably recommend against that in code review, but it's not absurdly obfuscated.

On Sun, Jul 8, 2018, 1:15 PM Giampaolo Rodola' <g.rodola at gmail.com> wrote:

On Sun, Jul 8, 2018 at 6:45 PM Steve Holden <steve at holdenweb.com> wrote: On Sun, Jul 8, 2018 at 10:41 AM, Giampaolo Rodola' <g.rodola at gmail.com> wrote:

​[...] I find that (space between the parentheses of a function call statement) too unnatural as a place where to put an assignment. It is not even "guarded" by a keyword like "if" or "while" which can help as indicators that an assignment may occur. Also, I think it's way too easy to confuse it with a keyword argument:

>>> foo(x = 1) # keyword arg >>> foo(x := 1) # assignment + value passing ​[...]

​But the PEP 8 spellings are​ foo(x=1) and f(x := 1). The extra spacing makes it obvious that this isn't a regular named argument. What if the author of the code I'm reading didn't respect PEP-8? I don't think it's fair to invoke PEP-8 as a counter-measure to obviate a syntax which can clearly be mistaken with something else simply by omitting 2 spaces. Not to mention that I don't see why anyone would want to declare a variable in there in the first place. -- Giampaolo - http://grodola.blogspot.com


Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/mertz%40gnosis.cx -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180708/fe93e92c/attachment.html>



More information about the Python-Dev mailing list