Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Absolute vs Relative Imports in Python: Overview

Give Feedback

If you’ve worked on a Python project that has more than one file, chances are you’ve had to use an import statement before. Even for Pythonistas with a couple of projects under their belt, imports can be confusing!

If you’re reading this because you’d like to gain a deeper understanding of imports in Python, particularly absolute and relative imports, then you’ve come to the right place! In this tutorial, you’ll learn the differences between the two, as well as their pros and cons.

Videos playing but no audio.

Dan Bader RP Team on Sept. 16, 2019

Sorry folks, I can’t seem to be able to reproduce this—the videos are playing fine on my end (tested in various browsers). I recommend you check out our “video playback issues” troubleshooting docs.

Looney on Sept. 18, 2019

what can be the use cases where we should add our package in sys.module . ?

Joe Tatusko RP Team on Sept. 18, 2019

Manipulating sys.modules isn’t something you normally have to think about. That is where any module that has been previously imported is stored, so you add modules and packages to it just by importing them.

It might help to think about it this way:

import pandas as pd

print("Pandas imported!")

import pandas as pd

print("Pandas imported again!")

In this example, the first time you import pandas Python is going to look in the sys.modules cache, and not find it (assuming this is the only script that is running). It then looks in the built in modules, and then will look in sys.path for the location of pandas. When you try to import it a second time, Python is able to find it in sys.modules, so it doesn’t need to continue searching or load it again.

Looney on Sept. 19, 2019

Thanks for explanation.

Become a Member to join the conversation.