Opened 4 years ago

Closed 4 years ago

#31555 closed Cleanup/optimization (duplicate)

Use .format() and f-strings in the polls tutorial.

Reported by: Alexandre Poitevin Owned by: nobody
Component: Documentation Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Some part of the tutorial contains the old format way (with the % operator)

return HttpResponse("You're looking at question %s." % question_id)
response = "You're looking at the results of question %s."
return HttpResponse(response % question_id)

I think it’s better to guide newcomers to the new way.
I’m ready to submit a patch for this if there’s nothing against it.

Change History (2)

comment:1 by Alexandre Poitevin, 4 years ago

Summary: Use .fortmat() and f-strings in the polls tutorialUse .format() and f-strings in the polls tutorial

comment:2 by Mariusz Felisiak, 4 years ago

Resolution: duplicate
Status: newclosed
Summary: Use .format() and f-strings in the polls tutorialUse .format() and f-strings in the polls tutorial.

There is nothing wrong in % format. I don't see any reason to prefer .format(), see discussion. We could consider using f-strings, but that's a duplicate of a more general ticket, see #29988.

Note: See TracTickets for help on using tickets.
Back to Top