dimanche 13 décembre 2015

run another .py file when condition is true

I'm very new to Python and trying to make a small project in Raspberry Pi2 with Python

Currently I have 2 code files run1.py and run2.py

I would like to write an if-else condition in Project.py but I'm not sure how to write the code properly....

if (condition is true) ----> run the code from file "run1.py"
else ----> run the code from file "run2.py"

Is it about the topic of '__main__' or import os? i'm trying to understand how it works too but not really understand yet.

Thank you

Aucun commentaire:

Enregistrer un commentaire