I have a CLI script which uses the logging module to print to screen and file. Is it possible to make ouput look better when breaking long lines for PEP8 using \?
logger.warning("SKIPPED File: '%s'; \
MyFunc() returned no results."
% (dir_file, ))
# You have to scroll to see the result -->
WARNING----SKIPPED File: 'test-filetypes/client-somefile.txt'; MyFunc() returned no results.
Yes, use implicit string concatenation:
logger.warning(
"SKIPPED File: '%s'; "
"MyFunc() returned no results.",
dir_file,
)
Note: I've fixed one other detail here - you shouldn't eagerly format your log strings. Just pass the template variable(s) along as arguments in the logging call.
strings right next to each automatically get appended so
logger.warning("SKIPPED File: '%s'; " \
"MyFunc() returned no results."
% (dir_file, ))
Should get you what you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With