I wonder what is better practice when using python 3 logging. a) logger.info("my message args are %s, %s", "a", "b") b) logger.info("my message args are {}, {}".format("a", "b")) is the first option more quick? I find the second option convenient since I can easily replace the logger.info with print command.
Asked
Active
Viewed 107 times
0
-
1Relevant: [Python: Logging TypeError: not all arguments converted during string formatting](//stackoverflow.com/q/12843099) – Martijn Pieters May 11 '17 at 07:30
-
As Martijn already gave an perfect answer: 'You cannot use new-style formatting when using the logging module; use `%s` instead of `{}`' – Ludisposed May 11 '17 at 07:37
-
@Ludisposed: logging can take care of the actual templating step. For that feature, only `%s` is supported. If you ignore that feature, there is nothing specific about logging here, and the question is a dupe. – Martijn Pieters May 11 '17 at 08:14