I have a file that I'm importing into my program (say a file with dictionaries). At the beginning of this file I want to put a strip of code which prints that this is not the main file and then exit()
. The problem I find is that this code is being run on import of the dictionaries module which I don't want happening. How to prevent that?
I tried this but it doesn't work:
if not Main_file:
print('These aren\'t the droids you\'re looking for')
exit()
in the main file there would of course be Main_file = True
before import.