Import folder in python

Code examples

3
0

import files from another folder python

# some_file.py
import sys
# insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '/path/to/application/app/folder')

import file
2
0

import local module python

# If the module is in the same directory:
import <module_name>

# If the module isn't in the same directory:
import sys
# insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '/path/to/application/app/folder')

import <module_name>
0
0

importing python modules from a folder

#place the file to be imported, named <imported file>, to the same folder as the python document
#defined function within the <imported file> is <function>
from <imported file> import <function>
#Note that <function> has no parenthesis at the end
0
0

import folder from another folder python

sys.path.insert(1, '/path/to/application/app/folder')

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................