There are several ways to do this:
As @cricket_007 states you can install SublimeREPL and run the current file via Tools >>> SublimeREPL >>> Python >>> Python - Run current file
. This interprets the python file in a Sublime Text view and inputs are possible. However since this is not a build system you can create a build system from this (click Tools >>> Build System >>> New Build System...
and paste):
{
"target": "repl_open",
"encoding": "utf8",
"syntax": "Packages/Python/Python.tmLanguage",
"extend_env": {"PYTHONIOENCODING": "utf-8"},
"type": "subprocess",
"cmd": ["python", "-u", "$file"],
"cwd": "$file_path",
"external_id": "python",
"selector": "source.python"
}
As an alternative one could run the file in a terminal, by using the following build system. This will create a new terminal and execute the file in python and afterwards await pressing enter.
{
"selector": "source.python",
"windows": {
"shell_cmd": "start \"$file_name\" cmd /c \"python $file_name & pause\""
},
"linux": {
"shell_cmd": "xterm -T \"$file_name\" -e bash -c \"python $file_name; echo Press enter to exit... & read\""
}
}
Feel free to add the osx option