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
Doc: printf-style library/stdtype improvements #16741
base: main
Are you sure you want to change the base?
Conversation
Doc/library/stdtypes.rst
Outdated
|
||
If *format* requires a single argument, *values* may be a single non-tuple | ||
>>> print('%s has %d quote types.' % ('Python', 2)) | ||
Python has 002 quote types. |
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.
This is not the right output.
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.
Fixed.
@Mariatta Could you help us out with this PR please? :) |
Thanks, but I think this mostly isn't an improvement. The old wording is more precise and accurate. For example, the new wording says "instances of %
in string
are replaced", but in fact it is %
plus some following characters. The new wording says "This operation is commonly known as string interpolation", but in my experience it's usually called something like "%-formatting".
The example is useful, though.
The effect is similar to using the :c:func:`sprintf` in the C language. | ||
The % operator (modulo) can also be used for string formatting. Given ``'string' | ||
% values``, instances of ``%`` in ``string`` are replaced with zero or more | ||
elements of ``values``. This operation is commonly known as string |
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.
I'd have to agree with Jelle's comment and also note that what's common can be somewhat subjective (for example, I'd search with the query string formatting
instead of string interpolation
, despite the wikipedia page). Would you be interested in updating the PR to address the review?
Making printf-style string formatting section in library/stdtype consistent with this conversation #16251