Python Package Basics


In this article, we will see how to use packages in Python. We can use packages as a namespace and organize a big project.

Step 1 : Create the Structure

In the root of the project folder, create the folders and files

Directory Structure
├── hive
│   ├──
│   ├──

The is an empty file. It tells Python to treat hive folder as a package. The hive is the package directory.

Step 2 : Write Code for the Package

The contents of
def hello():
    print("Hello from Hive!")

Step 3 : Write Python Program

You can now use the package in your code.
from hive import server


Step 4 : Run the program

From the project folder:

Run Program Command
Hello from Hive!

We now have a working setup for creating and using packages.