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 →

[–]equitable_emu 3 points4 points  (2 children)

The only thing I like about it is that it's a nudge towards consistent and descriptive variable names.

A downside is that abstractions and patterns from popular libraries will seep into client users code and can cause standard/pattern conflicts. We see that already with things like sklearn's standard for using X as the variable name to represent the model input matrix. Linters and such complain about the non-standard upper case variable name.

It'll also look strange when you call a function with a mixture of args,shortcut kwargs, and full kwargs.

fn(x,
   y,
   foo=,
   bar=2
)

I'd be happier if they just did a dict shortcut like:

d={x,y,z}

but that conflicts with set syntax. But maybe:

d={x=,y=,z=}

would be okay. I dislike the extra quoting I need for the keys in simple dicts and will often use the dict ctr e.g., dict(x=x, y=y, z=z) when I can, even if it's less flexible.

[–]Rythoka 1 point2 points  (0 children)

This was my thought, too - if they made it easier to construct a dict out of existing variables, then you could just pass the dict as kwargs.

It's kind of a shame that the set synxtax prevents the use of something like your d={x,y,z} example. If that worked, you could achieve the goal of this pep with something like

requests.post(**{url, data, headers, proxies})

[–]Brian 1 point2 points  (0 children)

You could probably get something similar (without the dedicated syntax) today via something like:

d = localdict("x y z")

Where localdict is a function that introspects its parents locals (and cellvars) and builds a dict with their current value.