Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

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: Summary

Give Feedback

Congratulations! You’re now up to speed on how absolute and relative imports work in Python. You’ve learned the best practices for writing import statements, and you know the difference between absolute and relative imports.

With your new skills, you can confidently import packages and modules from the Python standard library, third party packages, and your own local packages. Remember that you should generally opt for absolute imports over relative ones, unless the path is complex and would make the statement too long.

aradim on Sept. 11, 2019

Thanks , very helpfull

Chasp on Sept. 11, 2019

Succinct and understandable… good job!

abakala on Nov. 19, 2019

Thanks, it was very helpful!

Sachin on Dec. 17, 2019

Nice, clear and simple explanation!! This is first time I have understood this!!

Priya katta on Dec. 20, 2019

very helpful…thanks!

Pakorn on Jan. 1, 2020

Good job. Thanks

Crystal Taggart on May 18, 2020

I’d recommend adding a video for this command for relative imports:

import sys sys.path.append(“..”)

Alan ODannel on July 15, 2020

Very helpful. I put this to immediate use cleaning up a Python application that I inherited at wok.

Sid Price on Oct. 12, 2020

Really enjoyed the import course!

I have a project folder structure and import situation I do not seem to be able to resolve, so, hoping you can help me.

I have:

Project Folder:
    App Folder named 'app'
        Widgets Folder named "widgets'

In the app folder I am developing a dialog widget and I would like to test it standalone. It has code in it that when the module is the “main” module it creates an application object and instantiates the dialog for testing.

The issue I face is that the dialog widget requires access to modules in the “App Folder” and I cannot figure out how to do that.

You advice would be much appreciated. Sid

Ghani on Oct. 26, 2020

Very good course; thanks!

Become a Member to join the conversation.