I've got a (newby) question. I've written several modules now for several functions to do. Some of them I test/run when I edit them to see if I did things right.
Up until now I've made some kind of boolean switch in the module:
# myModule.py
run = True
if run:
* do stuff *
And then switch it off when I finish it and save it. But somethimes I forget to switch it off and then it also gets run when I import it from my main file.
My question: Is there a code that only lets it run when I opened the file and run it directly from this file? (So, not when imported from another file)
Many thanks for any tips/help on this subject.