I've been confused about this for a while now, I still have no idea what from x import y
really means. All I know is that it imports y from the file x(?)
Asked
Active
Viewed 122 times
0

Addicted2Cookies
- 84
- 2
- 10
-
[This](https://stackoverflow.com/questions/12270954/difference-between-import-x-and-from-x-import) might help. Or [this](https://stackoverflow.com/questions/710551/use-import-module-or-from-module-import). Or [this](https://stackoverflow.com/questions/9439480/from-import-vs-import?noredirect=1&lq=1) – Aven Desta Dec 30 '20 at 05:38
1 Answers
0
Suppose you have file name x.py
and that file there has a multiple function module like
def a():
print('You\'re A!')
def b():
print('You\'re B!')
def c():
print('You\'re C!')
def d():
print('You\'re D!')
.........
From the above x.py
file when you need a specific module a
then you can define that module name by from x import a
. When you need to import all module from the x.py
you can define then from x import *
.

mhhabib
- 2,975
- 1
- 15
- 29