Sublime Forum

How to take user input in console window, for python program?

#1

Usually I use Terminality package for taking user Input and running Python program. But it is a very time consuming process. The default Build system of Sublime Text-3 although does run python program in console window, at pop up in bottom of screen but there is no functionality of taking user input in it, at least as far as I know. Is there any way by which I can do so ?

0 Likes

#2

I have created a build system to run the python program in the terminal, such that it accepts user input:

{
    "selector": "source.python",
    "windows": {
        "shell_cmd": "start \"$file_name\" cmd /c \"python $file_name & pause\"",
    },
    "linux": {
        "shell_cmd": "xterm -T \"$file_name\" -e \"python $file_name; echo Press enter to exit... & read\"",
    }
}
0 Likes

#3

is it for linux (ubuntu-16.04) and by terminal you meant the default console/terminal of sublime text 3 ?

0 Likes

#4

I mean the system terminal outside of Sublime Text. On linux this works if you install xterm (which may be installed already) or replace xterm by the terminal you are using, e.g. gnome-terminal.

0 Likes