msg254689 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2015-11-15 19:21 |
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"). |
|
|
msg254693 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2015-11-15 20:25 |
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. |
|
|
msg254712 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2015-11-16 05:37 |
I don't think a warning is necessary because of what "verbose" does. |
|
|
msg254716 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2015-11-16 06:27 |
Existing scripts can contain passing positional 'rename' argument: namedtuple('Point', 'x y', False, True). |
|
|
msg254718 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2015-11-16 07:31 |
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. |
|
|
msg254719 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2015-11-16 07:45 |
OK, leave it to you. But may be worth to add a versionchanged directive. |
|
|
msg264942 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-05-06 06:57 |
Ping. If the keyword-only changes can be made without deprecation, I would want to make such changes for json functions (). json.dump() takes 11 positional parameters! Guido, what you say about this? |
|
|
msg264984 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2016-05-06 15:45 |
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). |
|
|
msg264986 - (view) |
Author: Guido van Rossum (gvanrossum) *  |
Date: 2016-05-06 15:47 |
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. |
|
|
msg264989 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-05-06 16:01 |
Then namedtuple_keywords.diff LGTM. But please document changes. |
|
|
msg267783 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-06-08 05:12 |
Ping. |
|
|
msg272765 - (view) |
Author: Serhiy Storchaka (serhiy.storchaka) *  |
Date: 2016-08-15 14:48 |
Ping again. |
|
|
msg272870 - (view) |
Author: Roundup Robot (python-dev)  |
Date: 2016-08-16 17:56 |
New changeset f086d6c9d9f6 by Raymond Hettinger in branch 'default': Issue #25628: Make namedtuple "rename" and "verbose" parameters keyword-only. https://hg.python.org/cpython/rev/f086d6c9d9f6 |
|
|