0

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?

0

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

1 Comment

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... :(
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 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.