Sublime Forum

Python Interactive Interpreter

#1

I would like to use Sublime as a python IDE. My standard workflow involves writing scripts and then debugging them with the interactive interpreter. I would like to be able to “build” and run the python file, with Ctrl-B and then drop into an interactive interpreter. Unfortunately if I edit Python.sublime-build to include the interactive flag “cmd”: “python”, “-i”, “$file”], the pop up shell displays a prompt symbol >>> but then immediately terminates with [Finished].

Is there a way to overcome this?

I am using Sublime 2 Build 2165.

Thanks in advance for any help.

0 Likes

#2

I think that you should be able to find something… if you look closely :mrgreen:

↓↓↓↓↓↓↓↓↓↓↓

0 Likes

#3

Hi wuub.

I actually discovered SublimeREPL a while after posting this. It seems very close to what I want indeed.

Quick question, is there anyway for me to set a keyboard shortcut to launch the appropiate REPL environment for the particular file I’m working on?

Is there anyway to make the REPL feel more like a traditional python interpreter environment? I.e. with the up arrow browsing through past history etc.

Sorry if I am nitpicking, and or asking for for something not possible, apart from these little things your plugin seems to be everything I am after.

Best Regards,

Jonathan

0 Likes

#4

Yes, but I din’t have enough time to set it up for every REPL yet. Take a look at ./SubimeREPL/config/Clojure/Default.sublime-[keymap|commands]. If you can wait, I’ll add all repls to command menu tonight, and then you can define whatever shortcut you like.

To a degree yes. for history try Alt+P, and ALT+N , and for rudimentary text-transfer support there is [F2, s] - send selection, [F2, l] - send lines with cursor in them and [F2, f] - send whole file to running interpreter.

[code]>>> x = 12

y = 42
x[ALT+P][/code]
But by default nothing fancy or terminal-like (eg. interpreter’s tab completion) will work. This is due to the way SublimeREPL is designed. It’s a simple STDIO driven plugin, actually at first it was only a Telnet plugin with SublimeText2 used as libreadline. In other words: every sublime text edit function (snippets, auto-completion, …) are at your disposal, but there is no background communication with the interpreter going on at the moment and nothing will be context-aware.

know the limitations of this plugin very well :smile: This is why SublimePTY is in the works. IMO there is also a place for language specific shells, maybe built on top of SublimeREPL. But for this to work the interpreter has to be able to cooperate with sublime plugin, and that’s a lot of work.

0 Likes

#5

I added the following to my user keymap

{ "keys": "f8"], "command": "repl_open", 
                 "caption": "Python",
                 "mnemonic": "p",
                 "args": {
                    "type": "subprocess",
                    "encoding": "utf8",
                    "cmd": "python", "-i", "-u", "$file"],
                    "cwd": "$file_path",
                    "syntax": "Packages/Python/Python.tmLanguage",
                    "external_id": "python"
                    } }
]

Seems to do the job for now.

I’ll keep an eye out for your updates!

0 Likes

Start SublimeREPL at startup by default