Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The reason you get warned for doing

`logger.debug("Got %s results", num)`

instead of

`logger.debug("Got {} results".format(num))`

is that in the first case, internally it checks if the logger is disabled and if so skips formatting the string, whereas in the second case you've already formatted it before passing it in, so that work can't be avoided. This isn't the case for print statements because they don't execute conditionally, so you don't ever skip doing the format.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: