New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make namedtuple "verbose" and "rename" parameters into keyword only arguments #69814
Comments
This is a usability and readability improvement made possible by Python 3's keyword only arguments. Usability is improved by getting a much less confusing response from the following mistake: namedtuple('Point', 'x', 'y')
^--- invisibly goes to the "verbose" argument The "verbose" argument is normally used interactively (much like help() and dis()) or is used with a keyword argument, so it is unlikely that existing scripts will be much affected. For the rare cases, the remediation is simple and improves code clarity (replacing "True" with "verbose=True"). |
I like the idea. But this is backward incompatible change. I would first add a warning. Here is a patch. Yes, the code looks a little cumbersome, but this is only for one or two releases. |
I don't think a warning is necessary because of what "verbose" does. |
Existing scripts can contain passing positional 'rename' argument: namedtuple('Point', 'x y', False, True). |
My judgment call is that the keyword-only change can be made directly, that the costs and clutter of deprecation and delay aren't worth in it this case, that the nature of the "verbose" and "rename" arguments puts this in the rare-to-non-existent category, that any remediation would be trivial (easier than shutting-off a warning), and that the user's come out ahead with the cleaner cut-over in this case. There's no value in being pedantic on this one, some judgment is required. |
OK, leave it to you. But may be worth to add a versionchanged directive. |
Ping. If the keyword-only changes can be made without deprecation, I would want to make such changes for json functions (bpo-18726). json.dump() takes 11 positional parameters! Guido, what you say about this? |
I think such a change can be safely made in a feature release (say 3.6) without further deprecation. But not in a bugfix release (say 3.5.2). |
And by "safely" I mean that I don't mind if some code breaks when they upgrade to a new feature release. FWIW the code most likely to break is code that wraps these functions with an identical interface. |
Then namedtuple_keywords.diff LGTM. But please document changes. |
Ping. |
Ping again. |
New changeset f086d6c9d9f6 by Raymond Hettinger in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: