Sublime for running Python

User question:

I downloaded the Sublime Text but I didn’t understand what it would be used to. It doesn’t run applications I guess, so It would be used only for editing the code (compas) itself?”"

Sublime Text, (latest version 3 can be found here), is a great program for editing and running Python scripts. By default you can run (build) a Python .py file by pushing CTRL+B. A small console will appear at the bottom with the feedback and completion time.

You can also install the add-on package SublimeREPL, which will allow you to interact and debug with the Python terminal after it runs the code, this is not the case for the building method as above. You can find it here. I recommend the following shortcuts to easily run a file or line of code in SublimeREPL:

[
    {"keys": ["f5"], "command": "repl_transfer_current", "args": {"scope": "file"}},
    {"keys": ["f9"], "command": "repl_transfer_current", "args": {"scope": "selection"}},
]

The methods will use your base system Python installation, which may not for example be Anaconda (if installed). Both the standard build and REPL methods can be set-up for different Python environments/versions.

As an alternative, VS Code supports Anaconda and virtualenv environments out of the box, and an interactive debugger as well.

To disable autocomplete when using the REPL console, set the following in the SublimeREPL settings:

{
    "repl_view_settings": {"auto_complete": false, "tab_completion": false}
}

I also recommend the WordHighlight package, which shows you word matches in the current file for what is currently under the cursor. Remember you can also use the CTRL+D shortcut to select consecutive matches of this word. I use these settings to further enhance the highlighting.

{
    "draw_outlined": false,
    "highlight_when_selection_is_empty": true,
    "mark_occurrences_on_gutter" : true,
    "highlight_delay" : 0,
    "show_word_highlight_status_bar_message" : true
}

Most of us also use the Anaconda package (this is separate from the Anaconda Python distribution), which among many very useful things, has a PEP8 linter. To disable specific PEP8 warnings, you can use the following for a list of the PEP8 codes you want to ignore:

{
    "pep8_ignore": ["E501", "E221", "E741", "E241", "E722", "E402", "E222"]
} 
1 Like