by ploxiln · 5y ago · 0 comments
logging.debug("%s", f"Unexpected, got {got}")
because otherwise, if the format string is the first/only argument, and `got` unexpectedly contain `%`, an exception will be raised due to a missing format parameter.(Also, for the logging functions, you don't pass a tuple, just a normal series of arguments.)
import logging
got = "%d"
logging.warning(f"hi {got}")
logging.debug(f"hi {got}")
Output WARNING:root:hi %d
DEBUG:root:hi %d