How to mark directory on disk as a Python package

To mark a directory as a Python package directory you have to put a file named __init__.py in this directory.

for example,

myproject/libraries/__init__.py
myproject/libraries/mymodule.py
myproject/main.py

you can import mymodule.py in main.py as:

import libraries.mymodule

or

from libraries import mymodule

The __init__.py file is usually empty.

Categories: Python Tags: , , , ,
%d bloggers like this: