Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (1.6k points)

I have a directory that stores all the .py files.

bin/ # where class User resides # where class Dir resides

I want to use classes from and in

How can I import these Python classes into

Furthermore, how can I import class User if is in a sub directory?



1 Answer

0 votes
by (25.1k points)

Firstly create an empty file named and save in the directory with your modules. This will indicate python that it is ok to import form this directory. Then you can import files like this:

from user import User

from dir import Dir

Related questions

0 votes
1 answer
0 votes
2 answers
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories