TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

PEP 736 – Shorthand syntax for keyword arguments at invocation

24 pointsby jiceaover 1 year ago

4 comments

belvalover 1 year ago
Frankly I'm a bit torn on this one as f(x=x) is indeed a common pattern and having just f(x=) reduces the need for multiline invocations but I feel like adding syntatic sugar to python at this point is just giving the snake diabetes.
评论 #38950469 未加载
mborchover 1 year ago
Since any argument after one or more &quot;**&quot; must be a keyword-argument, perhaps f(pos_a, pos_b, **kwargs, kw_a, kw_b, ...) or even f(pos_a, pos_b, **, kw_a, kw_b, ...).<p>This would make the proposal&#x27;s first example read:<p><pre><code> my_function(**, my_first_variable, my_second_variable, my_third_variable) </code></pre> More readable IMHO. They do mention f(a, b, *, x) in the proposal and present some objections, but arguably ** makes it easy to understand that these are keyword arguments.
zarzavatover 1 year ago
Finally! This makes constructing dicts so much easier. I somewhat dislike the syntax though, =foo would have been better because it stands out more. I feel like syntax should be chosen with eyes and not brain, they may have all kinds of rationales for why foo= is better but it&#x27;s just going to get lost more easily.
HackerThemAllover 1 year ago
my_function(my_first_variable=, my_second_variable=, my_third_variable=)<p>The coder&#x27;s laziness have gone too far. That&#x27;s ridiculous.<p>Just checked, the author is a Google folk, that says a lot.
评论 #38951598 未加载
评论 #38951207 未加载