1

I'ld like one of these:

  1. Starting python with a script like python my_routines.py and let python enter the interactive state while the code in my_routines.py have been loaded/run.

  2. Starting python in the interactive mode and loading in some convenient(short and easy to remember) way my_routines.py

the idea is, of course, that I want to preload some stuff and then play around with it in the interactive mode.

Suggestions involving loading a module (python -m ....) don't have to apply ;-)

Looking forward to your ideas!

Twan

1

1 Answer 1

8

To continue in REPL after running the script, run it with python -i test.py, where -i stands for interactive.

For loading from inside the REPL, you could use exec, but your best bet is to use ipython and its %load command. (ipython is an improved repl, so you should be using that anyway)

Sign up to request clarification or add additional context in comments.

2 Comments

Ah, of course, the -i option forgot that one. Thanks. The exec is a good tip. Sadly in the current application ipython is out of the question. Thanks!
ipython is better? This is the first I hear of this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.