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

Python; how to start an interpreter from a python file?

I have a python file and within that file I want to start an interpreter within that context. Is that possible?

I’m currently starting an interpreter and then using exec to load in the file, but it would be quicker and easier to do it the other way around.

The use case is loading in a file full of data and helper functions that I then want to play around with in the interpreter.

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 :

-i flag when running Python interpreter makes you stay in the interpreter after script finishes running.

python -i file.py
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