Uniform formatting format across library
See original GitHub issueThe current library uses a mix of "" %
, "%s".format
and "{}".format
everywhere.
"" %
formatting is heavily outdated (up for debate), alongside it being relatively un-pythonic.
Since python 3.6 (the current minimally supported version of this library), “f-strings” were introduced, this formalizes down from "{}".format
into f"{}"
:
value = "supercalifragilisticexpialidocious"
# Percentage formatting with symbol
"%s" % value
# Percentage formatting with format call
"%s".format(value)
# Brace formatting with format call
"{0!s}".format(value)
# Brace formatting with f-string
f"{value!s}"
Even if f-strings would not be a good, viable or a desirable candidate, I at least am asking if there would be a consistent formatting style across the library. With a coding style document somewhere to note this down, and/or linters to enforce this (flake8-pep3101
, flake8-string-format
).
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (8 by maintainers)
Top Results From Across the Web
Samples of Formatted References for Authors of Journal Articles
The recommended style for references is based on the National Information Standards Organization NISO Z39.29-2005 (R2010) Bibliographic References as adapted by ...
Read more >Formatting tips - Referencing - Library Guides at James Cook ...
"Double-space between all text lines of the manuscript. Double-space after every line in the title, headings, footnotes, quotations, references, ...
Read more >Three ways to expose formatting inconsistencies in a Word ...
The safest formatting route is a style, a collection of formats saved as a single unit. Even if you don't manually apply a...
Read more >Format Citations & Bibliography - Citation Tutorial
What we have provided below is a brief guide to the hallmarks of formatting within each of the major styles, and explanations about...
Read more >The MARC 21 Formats: Background and Principles
The following statement of background and principles for content designation in the MARC 21 formats was approved by the American Library Association's ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So to summarize, and to make sure I got it right:
f-strings everywhere, except for log entries, which use
%s
(with its built-in formatter), correct?Note that there are good reasons why logging statements should use
%s
style formatting. 👍 to all of the others being consistent.f-strings
are the current standard we’re using elsewhere.