When writing a program, making sure it works the way it’s supposed to is a crucial part of the process. This means you have to test your code, and you almost always end up with bugs that you have to debug.
When you are using a IDE, you often have nice tools to do that, with the ability to place breakpoints, observe the call stack, the content of the locals… But sometimes you find yourself in situation where your program lives somewhere else and you can’t use those nice modern tools, and you have to find an other solution.
If you are using Python, have some good news for you: the standard lib comes with a basic debugger included, pdb which we’ll discover today.
In a recent post about the
__path__ attribute, I explained that it would be possible to manipulate a library’s path to dynamically extend its functionalities. At the end of my article I detailed that this possibility has already been thought of was integrated in the import system since Python 3.3 with PEP 420, under the name of namespace package.
Today I’d like to go a bit more in details about this.
Recently, when preparing an article about Python import system, I discovered the
__path__ attribute and found some cool stuff to do with it, so I wanted to show what I discovered.