Section idea: Elegant string formatting
@mpoulin ya está trabajando en esto.
Desde el 31/8/2018.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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?
- Lenguaje dominante
- Batchfile
- Estrellas
- 29.8k
- Forks
- 5.9k
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de realpython/python-guide
-
Page 404 error Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
realpython/python-guide#1104 · 2 comentarios ·
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 62/100
realpython/python-guide#327 ·
-
PyZMQ improvements Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
realpython/python-guide#326 · 5 comentarios ·
-
@alex Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
realpython/python-guide#1194 ·
-
Development Team SAP Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 10/100
realpython/python-guide#1192 ·