Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Update "Format String Syntax" documentation block to match actual behaviour#132736
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
python-cla-botbot commentedApr 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
StanFromIreland commentedApr 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
See:#127833 We could update the whole snippet now. I'd ask Petr for what his plan was but he's unavailable at the moment. |
Doc/library/string.rst Outdated
arg_name: [`~python-grammar:identifier` | `~python-grammar:digit`+] | ||
attribute_name:`~python-grammar:identifier` | ||
arg_name: [`~python-grammar:digit`+ | `attribute_name`] | ||
attribute_name:<any source character except "]" or "."> + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Any?
Are you sure that can use bothN
andℕ
as attribute names?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You can even use]
:
>>classC:...def__init__(self,path=()):self.path=path...def__getitem__(self,key):returnC((*self.path,key))...def__getattr__(self,name):returnC((*self.path,name))...def__str__(self):returnstr(self.path)...>>>'{].][{].\0!s}'.format_map(C())"(']', ']', '{', '\\x00')">>>'{.][{].\0!s}'.format(C())"(']', '{', '\\x00')"
attribute_name: <any source character except "]" or "."> + | |
attribute_name: <any source character except "{", "}", "[", or "."> + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You are right, thank you! 👍
Updated the PR. 👌
8ce5764
toce915de
Compare
Uh oh!
There was an error while loading.Please reload this page.
Hello, let me try to help a bit with docs.
Here is an string formatting example:
This behaviour differs fromFormat String Syntax:
So I updated
arg_name
andattribute_name
syntax in that section to follow the actual behaviour:identifier
withattribute_name
inarg_name
attribute_name
asanything that doesn’t contain "." or "]"
You can find original discussion threadhere
📚 Documentation preview 📚:https://cpython-previews--132736.org.readthedocs.build/en/132736/library/string.html#format-string-syntax