Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Importing a .py file opens it on startup of another file

I am importing a settings.py file into browser.py, like so:

import settings

But when I run the browser.py file then it opens settings.py before it runs browser.py, and I don’t want settings.py to run. Is there a way to stop settings.py from running, while still importing settings into browser.py?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Any python code outside functions and classes will be automaticly ran when you import the settings file.

You can try put the code that you don’t to be executed inside a function in the settings file and then calling those functions in browser.py as you need them.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading