Join Nostr
2024-09-23 13:49:44 UTC

vestige on Nostr: What's more idiomatic Python in this case? We are generating a log file. Using ...

What's more idiomatic Python in this case?

We are generating a log file. Using f-strings, one common mssage template including variable names is well over the 89 characters that Black formatter likes and this project's flake8 linter is configured for.<li>We could split the f-string into two or three strings joined within parens. Seems awkward given it prints as a single line, but oh well.</li><li>We could assign single-character variable names to use in the format string and maybe get it under 89 characters?</li><li>We could use string interpolation (% operator) or .format and put the variables on a separate line. It looks clean to me but it's not as obvious what variable goes where in the output.</li><li>We could leave it as-is and annotate the code so flake8 ignores the long line, then go get a coffee.</li><li>... Profit?</li>

The variable names are short. I'm curious whether anyone here has any strong opinions on the issue. (There are certainly some opinions on Stack Overflow...)

#python #codereview