Quantcast
Viewing all articles
Browse latest Browse all 7

Answer by Flavio Wuensche for Import module from subfolder

Say your project is structured this way:

+---MyPythonProject|   +---.gitignore|   +---run.py|   |   +---subscripts|   |   |   +---script_one.py|   |   |   +---script_two.py

Inside run.py, you can import scripts one and two by:

from subscripts import script_one as Onefrom subscripts import script_two as Two

Now, still inside run.py, you'll be able to call their methods with:

One.method_from_one(param)Two.method_from_two(other_param)

Viewing all articles
Browse latest Browse all 7

Trending Articles



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