Python Code Reuse

Python Code Reuse

2018-07-01. Category & Tags: Default Python, Reuse, Import, Include

execfile or os.system #

execute the other python file in place:

execfile("/path/to/my/lib/mylib.py")

or:

import os
os.system("python /path/to/my/lib/mylib.py")

import #

import sys 
import os
sys.path.append(os.path.abspath("/path/to/my/lib"))
import mylib

ref #

See other methods here.