M
M
Mike Evstropov2016-01-15 13:20:29
Python
Mike Evstropov, 2016-01-15 13:20:29

How to import all modules from a directory?

For example from here:

import sys
sys.path.append('/module/')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2016-01-15
@Aroused

Create an __init__.py file in the directory
Mike Evstropov : Python recognizes the folder with this file as a package of modules. You can do this:

import sys
sys.path.append('/module/')
# в папке module есть файл __init__.py и moduleBest.py
# делаем импорт
from module import moduleBest

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question