Chap 11 Packagesword
Chap 11 Packagesword
Any folder or directory contains init .py file,is considered as a Python package.This file
can be empty.
init .py
File 1
File 1 File 1
Loan
nd
SKILLSOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
1 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www. skillsoft.com
init .py
File 1
File 1 File 1
Loan
Eg 1:
D:\Python_classes>
|-test.py
|-pack1
|-module1.py
|- init .py
init .py:
empty file
module1.py:
def f1():
print("Hello this is from module1 present in pack1")
test.py (version-1):
import pack1.module1
pack1.module1.f1()
nd
SKILLSOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
2 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www. skillsoft.com
test.py (version-2):
Eg 2:
D:\Python_classes>
|-test.py
|-com
|-module1.py
|- init .py
|- skillsoft
|-module2.py
|- init .py
init .py:
empty file
module1.py:
def f1():
print("Hello this is from module1 present in com")
module2.py:
def f2():
print("Hello this is from module2 present in com. skillsoft")
test.py:
nd
SKILLSOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
3 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www. skillsoft.com
Library
nd
SKILLSOFT, # 202, 2 Floor, HUDA Maitrivanam, Ameerpet, Hyderabad - 500038,
4 040 – 64 51 27 86, 80 96 96 96 96, 92 46 21 21 43 | www. skillsoft.com