Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pyctrl
Copy link

@pyctrl pyctrl commented Apr 19, 2025

Hello, let me try to help a bit with docs.

Here is an string formatting example:

In [29]: "{a-b} {-}".format(**{"-": "_-_", "a-b": "ABC"})
Out[29]: 'ABC _-_'

This behaviour differs from Format String Syntax:

arg_name: [identifier | digit+]
attribute_name: identifier

So I updated arg_name and attribute_name syntax in that section to follow the actual behaviour:

  • replaced identifier with attribute_name in arg_name
  • set syntax for attribute_name as anything that doesn’t contain "." or "]"

You can find original discussion thread here


📚 Documentation preview 📚: https://cpython-previews--132736.org.readthedocs.build/

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 19, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@StanFromIreland
Copy link
Contributor

StanFromIreland commented Apr 19, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants