Quantcast
Channel: Import module from subfolder - Stack Overflow
Viewing all articles
Browse latest Browse all 7

Answer by user418615 for Import module from subfolder

$
0
0

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 all articles
Browse latest Browse all 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>