4 ms·
Some people are saying the syntax is ugly, and I agree. But it addresses a real problem in Python: the names of the arguments of your public functions are also
by alexbecker 7y ago
Some people are saying the syntax is ugly, and I agree. But it addresses a real problem in Python: the names of the arguments of your public functions are also part of your public API (since they can be called as kwargs). In my experience, this is rarely desirable and makes fixing bad names unnecessarily hard.
- masklinn 7y agoAnd worse, they cause problems in some APIs e.g. defining / overriding MutableMapping.update(), it should take a single optional positional-only parameter and any number of keyword arguments, currently this requires using *args and hand-rolled assertions, otherwise you can get kwarg conflicts and other such issues.
- js2 7y agoFunction names and class names are also part of your API and there's no facility to allow those to be arbitrarily renamed. Being able to rename positional parameter names is a very weak argument in favor of this feature. The only argument I'm even remotely sympathetic to is "If a function uses a name for a parameter, that precludes callers from using it as a keyword argument elsewhere in the argument list." But the workaround for that rare case is to use: *args, **kwargs