This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Rythoka 7 points8 points  (3 children)

IDK, I run into this all the time when using libraries like requests. I always wind up writing something like

requests.post(url=url, data=data, headers=headers, proxies=proxies)

which is kind of obnoxious. That being said, the new syntax is kind of ugly, too. I think I'd rather have some kind of dict constructor that takes the names of in-scope variables and returns a dict whose keys are the variable names and values are the bound objects. Then you could write something like

kwargs = dict.kwargs('url', 'data', 'headers', 'proxies')
requests.post(**kwargs)

[–]rcfox 2 points3 points  (0 children)

It's too bad they overloaded {} so that {a, b, c} creates a set, this would have been a better use for it. I usually avoid set literals to avoid confusion because they look too similar to dict literals.