from <module_name> import *
# this represent importing all of the exposed functions and classes into your namespace
# so if you use a name same as a function in that module. Errors and incompatabalities occurs
(in python3) ---
from .filename import function_name
from time import sleep
# or import time
a = 10
sleep(4) # sleep function from time library
print(a)
import datetime #import module
from datetime import timedelta #import method from module
#You can also use alias names for both
import datetime as dt
from datetime import timedelta as td
# import modules/files/functions
import MODULE_NAME/PATH_TO_FILE # just import the module
import MODULE_NAME/PATH_TO_FILE as ... # imports the module "under some name"
from MODULE_NAME/PATH_TO_FILE import FILE/FUNCTION # imports just one file/function of the module
from MODULE_NAME/PATH_TO_FILE import FILE/FUNCTION as ...
from MODULE_NAME/PATH_TO_FILE import * # imports all functions/files from one module/file
import MODULE_NAME
from time import sleep as stop # changes the name of the function to anything you want
print("hi")
stop(3) # works the same as the function without the as
print("bye")
# To install a library
# In command prompt:
pip install <PACKAGE_NAME>
# To import a library
# In python:
import <PACKAGE_NAME>
# import statement example
# to import standard module math
import math
print("The value of pi is", math.pi)
from random import *
import module_name
from hello import *
# Ways to import in Python
import 'module_name'
import 'module_name' as 'name'
from 'module_name' import *
from 'module_name' import 'name', 'name'
from 'module_name' import 'name' as 'new_name', 'name' as 'new_name'