question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Uniform formatting format across library

See original GitHub issue

The 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:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ShadowJonathancommented, Dec 18, 2019

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?

1reaction
pipermerriamcommented, Dec 17, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found