filmov
tv
Logging - Intermediate Python Programming p.22
![preview_player](https://i.ytimg.com/vi/-RcDmGNSuvU/maxresdefault.jpg)
Показать описание
Welcome to part 22 of the intermediate Python programming tutorial series. We're going to be covering logging in Python .
The idea of Python's logging module is to make your life easier. Have you ever maybe added print functions/statements in your code at various places to note where your code is and what's running? Then maybe commented it out? Maybe you got fancy and created a constant like debug = True, then had some lines like if debug: print(something). If this sounds like you, or if it sounds like something that you might find useful, chances are, you should be using logging instead. Maybe you haven't yet needed to do such things, but, eventually you may find yourself in a situation where you do want to temporarily track what your code is doing, but not always. Using print can help in a pinch, but your life will be easier in the long run if you bake logging into your code early on. With logging, you can both output to console as well as saving to a file, all depending on varying debugging levels you can choose from.
The idea of Python's logging module is to make your life easier. Have you ever maybe added print functions/statements in your code at various places to note where your code is and what's running? Then maybe commented it out? Maybe you got fancy and created a constant like debug = True, then had some lines like if debug: print(something). If this sounds like you, or if it sounds like something that you might find useful, chances are, you should be using logging instead. Maybe you haven't yet needed to do such things, but, eventually you may find yourself in a situation where you do want to temporarily track what your code is doing, but not always. Using print can help in a pinch, but your life will be easier in the long run if you bake logging into your code early on. With logging, you can both output to console as well as saving to a file, all depending on varying debugging levels you can choose from.
Комментарии