3 ms·
Besides the mistake about dicts being ordered in Python which was pointed out by others, > Why wouldn't you simply switch to setting everything through kwargs
by JulianWasTaken 3y ago
Besides the mistake about dicts being ordered in Python which was pointed out by others,
> Why wouldn't you simply switch to setting everything through kwargs instead?
Not all arguments in Python are passable both ways.
In
def f(a, /):
print(a)
`a` may be passed only positionally.
- kstrauser 3y agoI'd argue that functions with only position arguments are a place where you'd never want to use this proposal, ever. A tuple or list would be the right data structure to pass in there.
- JulianWasTaken 3y agoOf course it would be irrelevant for a function that only took positional arguments. I was demonstrating the existence of such things in general since OP seemed unaware. For the proposal, you'd of course only use it for functions that took more kinds of arguments.
- necovek 3y agoThanks for pointing it out. Still, it seems highly unlikely someone would decide to use such a function declaration yet want to use the proposed syntax to pass both positional and keyword arguments.