Files
python-doc/Docs/Basic/06-pkg-modules.md

680 B

import emoji
print(emoji.emojize("abbas is :red_heart:"))
from emoji import emojize
print(emojize("abbas is :red_heart:"))

create modules

hi.py

def hi():
    print("Hi :)")

main.py

import hi
hi.hi()

create package

honor/hi.py

def hello():
    print("Hi :)")

honor/init.py

Can Be Empty But Must Be Exist

main.py

from honor import hi
hi.hello()

or main.py

from honor.hi import hello
hello()

name conecpt :

print(__name__)

if we run dirctly for example python3 abbas.py the output is main but if import it that is diffrent