PyGuy
PyGuy

Reputation: 551

run python script from command line and then enter interactive mode

Is there a way to run a python module from command line ( -m option, which imports and runs a module ), and then enter the interactive mode?

I need something similar to "cmd /k command".

I tested the -i option, but it didn't work; I'm not sure but it seems just redirects in_stream from input.

Upvotes: 4

Views: 3744

Answers (3)

slushy
slushy

Reputation: 3377

You need to put the -i before the -m.

The -m option is an interface option; it terminates the option list and all subsequent arguments will end up in sys.argv for the module's main function. (link to doc)

Upvotes: 3

M. K. Hunter
M. K. Hunter

Reputation: 1828

Or go into interactive mode and run your python file:

import <filename>

Upvotes: 1

Nir Alfasi
Nir Alfasi

Reputation: 53545

You can use bpython in the following way:

bpython -i <filename>

which will load the module and get into interactive mode

Upvotes: 0

Related Questions