Enter interactive mode after script execution with Python's -i flag

$ python -i script.py

You can start interactive mode directly after executing script.py by adding the -i flag.

Example

scripts.py


import numpy as np

def double_list(a):
    b =  np.array(a) * 2
    return b.tolist()

x = 'Hello'
$ python -i script.py
>>> double_list([1,2,3])
[2, 4, 6]
>>> print(x)
Hello

Recommended Posts

Enter interactive mode after script execution with Python's -i flag
Extend Python's interactive mode
Script execution at startup with ipython