Alphalearningschool
        

<<< Prev

Next >>>

Up
Python Package / Folder

Python package in simple word you have to make one folder then inside this folder you have to create or already their some python file.

Now you want to access this python file function or method in another python file for that what you have to do just create _init_.py file inside your package and import this class functionality over there so now you can easily access the method or function of particular class. 

This package facility provide by python is hierarchical directory structure where a package contain sub-package , module , sub-module.

This package facility will increase our code efficiency.

Let see the example,

Ex.
#sleeping.py
def sleep():
    print("sleeping..........")

 

#eating.py
def eating():
    print("Eating........")

 

#working.py
def working():
    print("Working.......")

 

#_init_.py

from eating import eating
from sleeping import sleep
from working import working

 

#disp.py

import Demo
Demo.eating()
Demo.sleep()
Demo.working()

 

Note** Above all this python file is in Demo python package.