GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||
GeezerVison is showing github.com — gh-96397: Document that keywords in calls need not be identifiers by jeff5 · Pull Request #96393 · python/cpython Conversation
|
|
Let’s create an issue so that it can be referenced properly! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
WIth two small wording nits I am in favor of this PR. Given the controversy around it I will request a SC member as a second reviewer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Guido's suggestions are the only comments I would have made.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Agreed. @merwok could you create the issue? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I agree this is behaviour of CPython that we don't intend to change. I.e. it is not a bug. However, is it a feature of the Python language that these non-identifier keywords are allowed or is it an implementation detail of CPython? The reality seems to be that other Python implementations like pypy and Graal have to do the same thing, in order to be compatible. It seems the trend is to avoid having undefined behaviour in languages. So, maybe it should be defined at the language level. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Issue created: #96397 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
@nascheme: There was a bunch of discussion about that in discourse, I don't think any consensus was reached.[*] Once an issue has been created, I guess that's where we could discuss it. OOPS -- I see it was created now -- I'll go there. I'd also like to document the same thing with [*} My $0.02: using non-valid identifiers as attribute names via |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Guido van Rossum <[email protected]>
Co-authored-by: Guido van Rossum <[email protected]>
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You can do setattr() in the same PR or in a separate PR linked to the same issue. Either way this won't be merged until someone from the SC agrees.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I would not do |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Interesting -- so you can stuff pretty much whatever want into an object's dict. However, if you do put a non-string key into a dict, it will store it just fine, but not be accessible by getattr(), and only be accessible by directly accessing the dict. I suppose it's possible that that could be a feature someone would (ab)use, but maybe the docs could advise against it, and/or call it unsupported? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
IMO it’s best for the docs to define the spec precisely, say something about strings that are not identifiers, but not also mention details of non-strings in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Wouldn't the safest option in short term be to precisely describe how the implementation works, and to categorize all of it as implementation details ? That way, programmers won't assume something is documented when it's just a behavior happening in their console. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sometimes documenting something that can be abused even if just to advise against it just leads to more abuse. So I'd lean towards not mentioning that you might be able to get away with stuffing a Regardless, for this PR as is, documenting that There are a pile of existing APIs in the world that take arbitrary keyword arguments and depend on this as a convenient feature. Many intentional, some maybe not wholly intentional but users who realize it enjoy the convenience anyways. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
@Gouvernathor This would be very much second best and not provide the consistency between implementations we hope for. The Language Reference aspires to document Python the language, and only occasionally (in grey boxes if we remember them) CPython the implementation. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Now that I think about it -- it seems it would not be too hard to have a dict that only accepts string keys -- but yes, that's a code change, so a new topic and not part of this PR. For the Typing folks: are the dunders often typed? that may be a place to define what a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Am I the one to request that? I would include #96454, but in a way that allowed a separate decision. Is there a proper place (like the PEP repo) that puts it on the agenda. E-mail to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Requests to the council are sent here: https://github.com/python/steering-council/issues/ |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Still waiting for the SC… |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Which I think this is waiting on me to ask it? I can draft this weekend (if I can slip by the King's forces currently encamped around PyConUK). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
In view of the SC decision, can this (and #96454) now be merged? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Thanks @jeff5 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-97025 is a backport of this pull request to the 3.11 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…rs (pythonGH-96393) This represents the official SC stance, see https://github.com/python/steering-council/issues/142GH-issuecomment-1252172695 (cherry picked from commit 9d432b4) Co-authored-by: Jeff Allen <[email protected]>
|
GH-97026 is a backport of this pull request to the 3.10 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…rs (pythonGH-96393) This represents the official SC stance, see https://github.com/python/steering-council/issues/142GH-issuecomment-1252172695 (cherry picked from commit 9d432b4) Co-authored-by: Jeff Allen <[email protected]>
…-96393) This represents the official SC stance, see https://github.com/python/steering-council/issues/142GH-issuecomment-1252172695 (cherry picked from commit 9d432b4) Co-authored-by: Jeff Allen <[email protected]>
…-96393) This represents the official SC stance, see https://github.com/python/steering-council/issues/142GH-issuecomment-1252172695 (cherry picked from commit 9d432b4) Co-authored-by: Jeff Allen <[email protected]>
…-96393) This represents the official SC stance, see https://github.com/python/steering-council/issues/142GH-issuecomment-1252172695 (cherry picked from commit 9d432b4) Co-authored-by: Jeff Allen <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Clarify status of non-identifier unpacked keyword arguments
There was an error while loading. Please reload this page.