Non-interactive debugging
The most basic form of debugging is adding a simple print statement into your code to see what is still working and what isn't. This is useful in a variety of cases and likely to help solve most of your issues. Later in this chapter, we will show some interactive debugging methods, but those are not always suitable. Interactive debugging tends to become difficult or even impossible in multithreaded environments, while on a closed-off remote server, you might need a different solution as well. Both methods have their merits, but I personally opt for non-interactive debugging 90% of the time since a simple print/log statement is usually enough to analyze the cause of a problem.
A basic example of this (I've been known to do similar) with a generator can be as follows:
>>> def spam_generator(): ... print('a') ... yield 'spam' ... print('b') ... yield 'spam!' ... print('c') ......