Relative Imports

Let's talk about relative imports and how it works.

Why do we need relative imports?

PEP 328 describes how relative imports came about and what specific syntax was chosen. The idea behind it was to use periods to determine how to relatively import other packages / modules. The reason was to prevent the accidental shadowing of standard library modules. Let’s use the example folder structure that PEP 328 suggests and see if we can get it to work:

Get hands-on with 1400+ tech skills courses.