Sublime - Run python in cmd
So I had some problems running python with the default ctrl+b console (inputs etc...).
I've tried SublimeREPL but it just didn't work that great.
So I've come up with a simple solution, opening the python file via the Command Prompt.
1) Preferences -> Browse Packages
2) Create a new folder named: "cmd"
3) Create a file in that folder called: cmd.py
4) Save cmd.py with the following contents:
import os, sublime_plugin, subprocess
class CmdCommand(sublime_plugin.TextCommand):
def run(self, edit):
path, _ = os.path.split(self.view.file_name())
subprocess.Popen(['cmd','/K',os.path.basename(self.view.file_name())])
5) Preferences -> Key Bindings - User:
[
{ "keys": ["ctrl+shift+c"], "command": "cmd" }
]
Restart, and have fun!
Written by Agam
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Python
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#