I'd like to make a py2exe distribution of a python program that invokes python with the -i command line option. Does anyone know if that's possible? Also, for this to work, do I need to do something about sys.exit()?
Asked
Active
Viewed 214 times
1
-
1For the sake of other readers: the `-i` flag to `python` is the "interactive mode" flag, which causes Python to display the interactive prompt after executing your `.py` file. – Li-aung Yip Mar 14 '12 at 05:20
1 Answers
1
You can start the interactive Python shell by invoking magic in your script^W^W^W^W manually calling the REPL. This would be roughly equivalent to the -i
flag (except you can start the interpreter at ANY time, not just at the end of your script.)
The magic looks like this (courtesy of Jason R. Coombs):
def interact():
import code
code.InteractiveConsole(locals=globals()).interact()

Community
- 1
- 1

Li-aung Yip
- 12,320
- 5
- 34
- 49