Section idea: Elegant string formatting
@mpoulin arbeitet bereits daran.
Seit 31.8.2018.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
One thing that I would love to see is an opinionated guide to elegant string formatting in python. I feel like there are many ways to do it, especially with f-strings now, and when it comes to indentation, interpolation, longer method names, etc, and I can never decide in the moment on what the most elegant approach is. This is especially hairy when trying to conform to a 79 character line length.
This seems obviously up the python guide's alley. ;) Just wanted to drop the seed in case it had ever crossed y'alls mind.
Some examples I can think of:
-
What should a long string parameter in a method call look like? (This often comes up in exceptions being raised for example.)
-
What should a long string parameter with interpolation in an error message look like?
-
What should a string look like in a case with deep-ish indentation? (other than: break out to a method). Same question with interpolation.
-
f-strings or
.format()or%? When/why? -
What should multi-line f-strings look like? Should they be avoided?
-
When to triple quote? Docs only?
etc
I feel like there's an opportunity for really good guidance here that is outside of pep8; something everybody would run into that you all would have well-formed opinions on. :) And I haven't seen much written about it.
Thoughts?
- Vorherrschende Sprache
- Batchfile
- Sterne
- 29.8k
- Forks
- 5.9k
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus realpython/python-guide
-
Page 404 error Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
realpython/python-guide#1104 · 2 Kommentare ·
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 62/100
realpython/python-guide#327 ·
-
PyZMQ improvements Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
realpython/python-guide#326 · 5 Kommentare ·
-
@alex Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
realpython/python-guide#1194 ·
-
Development Team SAP Offen
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 10/100
realpython/python-guide#1192 ·