filmov
tv
Lecture 19 import, from, as keywords in python #programmingwithashvini

Показать описание
#programmingwithashvini
please like and share or subscribe
Python modules can get access to code from another module by importing the file/function using import. The import statement is the most common way of invoking the import machinery, but it is not the only way.
The from keyword is used to import only a specified section from a module.
Difference between import and from in Python
Python's "import" loads a Python module into its own namespace, so that you have to add the module name followed by a dot in front of references to any names from the imported module that you refer to:
import feathers
"from" loads a Python module into the current namespace, so that you can refer to it without the need to mention the module name again:
from feathers import *
duster = ostrich("South Africa")
or
from feathers import ostrich
duster = ostrich("South Africa")
please like and share or subscribe
Python modules can get access to code from another module by importing the file/function using import. The import statement is the most common way of invoking the import machinery, but it is not the only way.
The from keyword is used to import only a specified section from a module.
Difference between import and from in Python
Python's "import" loads a Python module into its own namespace, so that you have to add the module name followed by a dot in front of references to any names from the imported module that you refer to:
import feathers
"from" loads a Python module into the current namespace, so that you can refer to it without the need to mention the module name again:
from feathers import *
duster = ostrich("South Africa")
or
from feathers import ostrich
duster = ostrich("South Africa")