Quantcast
Viewing latest article 7
Browse Latest Browse All 7

Answer by user418615 for Import module from subfolder

just tested and this worked:

# create sub dirmkdir ./modules

create module1.py

vim ./modules/module1.pydef hello():    print("hello have a nice day")def bye():    print("bye")

vim write and quit

:wq

include module1.py functionality into fileA.py and call it's functions

vim ./fileA.py#!/usr/bin/env pythonimport syssys.path.append('./modules')print("===== testing modules =====")import module1# call functions of the modulemodule1.hello()module1.bye()

Viewing latest article 7
Browse Latest Browse All 7

Trending Articles