How to import another class into python? I just started learning python and I don't understand importing. there are two files in one folder. How to import?
Asked
Active
Viewed 107 times
2 Answers
0
Its really easy.
If you want to import a class from another file just write at the start of the file.
from name of the file import name of the class
Remember to put the two files in the folder. :3

Guillermo Boscá
- 13
- 3
-
just the file name or extension? I have 2 file. First.py, and Second.py 2 file in 1 folder. i would like to import second.py in first.py... i can use import Sedond.py in the First.py file, but doesn't work... :( – TKDzsola Oct 18 '20 at 07:24
0
You can just import the file using the below command at the beginning of your python file. Keep both the file in the same folder.
import file_name

Aditya Rathi
- 5
- 4