Packages are directory with some specific classes, functions, etc. which we can use it later as per our convenience. We don’t save all the files in our computer system, so we create packages that are useful for later use and can be imported and used in our programs.
One or more modules can be put into a package. It must contain a special folder __init__.py.
Steps for creating a package:-
- Create a folder.
- Create a sub-folder with the same name.
- Place module files inside the sub folder.
- Create __init__.py folder.
- Create setup.py in the parent file.
- We have to make directory first with a name suitable for the use.
- Add some specific classes in it.
class class_name1: "class functions" class class_name2: "class functions"
- Now create __init__.py function so that we can import package.
form package_name import function_name . . program in which it is used . .
This is all about packages in python.