Does the logging module support f-string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Does the logging module support f-string?

format strings in python are really awesome. is it possible to use them in the ''format" keyword argument of the "logging.basicConfig" method? maybe like import logging logging.basicConfig(format=f'...')

28th Jul 2018, 9:43 PM
Romex
Romex - avatar
2 Answers
+ 3
I've never used it but according to the documentation it doesn't look like it... but it wouldn't hurt to try anyway 🙂 https://docs.python.org/3/library/logging.html#logging.basicConfig "If format is specified, use this style for the format string. One of  '%',  '{'  or  '
#x27; for  printf-style,  str.format()  or string.Template  respectively. Defaults to '%'."
28th Jul 2018, 10:10 PM
David Ashton
David Ashton - avatar
+ 1
thanks, I tried it out but got a traceback
30th Jul 2018, 8:29 PM
Romex
Romex - avatar