Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

adorilson
Copy link
Contributor

@adorilson adorilson commented Oct 13, 2019

Making printf-style string formatting section in library/stdtype consistent with this conversation #16251


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.
Copy link
Member

@serhiy-storchaka serhiy-storchaka Oct 18, 2019

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.

Copy link
Contributor Author

@adorilson adorilson Oct 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@adorilson adorilson requested a review from serhiy-storchaka Jan 23, 2021
@vinigfer
Copy link
Contributor

vinigfer commented Jul 27, 2021

@Mariatta Could you help us out with this PR please? :)

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

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
Copy link
Contributor

@slateny slateny Dec 10, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants