Python

Last updated 6 months ago

Import

thanks

Example, we have a lib called module.py

# module.py
def fun1(n):
return n+1

There are four way to import module.py

1- import

import module
module.fun1(1000) #1001

2- from

from module import fun1
fun1(1000) #1001

3- import *

from module import *
fun1(1000) #1001

4- import as

import module as lib
lib.fun1(1000) #1001