On Thu, Sep 13, 2018, 11:58 PM Anders Hovmöller <bo...@killingar.net> wrote:
> In that case, you should be able to link to a compelling example. If you >> go to the trouble of finding one, I'll take time to try to refactor it. >> >> >> https://github.com/django/django/blob/master/django/db/models/sql/compiler.py#L707 >> >> Is a pretty typical one. >> > > That call is recursive, so it's unlikely that the author would shift the > parameters around without testing the call and changing the argument > positions appropriately. > > > Maybe. Still it would be better with keyword arguments. Testing is one > thing, quickly finding problems is another. Keyword arguments fail fast and > cleanly with signature changes, positional arguments only do when you add > or remove parameters at the very end, all other changes are potentially > very annoying to debug because you can get a long way past the problem call > site before hitting a type or behavior error. > > I'm not sure we even agree on this basic point though. Do you agree on > that? > I agree those are benefits to keyword arguments, but I disagree that those benefits accrue in all cases. I do not believe that keyword arguments are strictly better than positional. Maybe our difference of opinion stems from tooling and the way others refactor the code we work on. I enjoy using keywords to explain the values I'm passing. If I already have a well-named variable, I'm less keen on using a keyword. Here's a possible refactor. I didn't bother with keyword arguments, because the variable names are easy to match up with arguments positionally. My screen was large enough that I could read the signature at the same time as I wrote the call. def recurse(name): return self.find_ordering_name(name, opts, alias, order, already_seen) return itertools.chain.from_iterable(map(recurse, opts.ordering))
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/