Sometimes, we want to import the class within the same directory or sub directory with Python.
In this article, we’ll look at how to import the class within the same directory or sub directory with Python.
How to import the class within the same directory or sub directory with Python?
To import the class within the same directory or sub directory with Python, we can import as a relative or absolute import.
For instance, we write
from .user import User
to import the User
class from the user
module same directory as the current script.
Conclusion
To import the class within the same directory or sub directory with Python, we can import as a relative or absolute import.