Thankfully, there is a better way. Since the first segfault in C, a class of tools called debuggers have emerged with every language. Python is no exception, with a default one baked right in. There are also some cool ones developed by the community.
If you feel "print debugging" isn't enough anymore, you might want to see other options available.