When you develop your Python programs you are going to need an editor to write your code and as well as a way to quickly execute that code. You will probably find yourself writing a bit of Python code, executing it to check your work, switching back to the editor and either making adjustments or continuing on with the rest of your application.
Code Editors vs. Integrated Development Environments
Let’s understand the difference between a code editor and an integrated development environment. And this is not as easy as it sounds. There is a fine line between the two.
In certain cases, it may not be possible to be exactly sure whether a tool is a code editor or an IDE. But in other cases, the distinction is quite clear. But at a high level, what are the characteristics of each one?
And so, a code editor can help by providing features to enhance the coding experience. In some cases, these features are included right from the moment when you install the code editor. In other cases, you may need to install a plugin or an extension.
Additionally, a code editor tends to be general purpose and usually not language specific, which has some advantages, as well as disadvantages. For example, being language specific can help you be more productive with a certain technology stack right away. But if you change it to a different one, you may need to retrain yourself.
With a general purpose or extensible code editor, it may be easier to jump from one language to another, simply installing additional plugins for your new languages as needed.
Also, availability may vary per operating system. You might have one that you love, but it only runs on Mac or only on Windows or only on Linux. Or maybe you’re lucky and it runs on all three. But then again, editing your code is only a part of a story, and that is where IDEs come into play.
With an integrated development environment, IDE, you get more than just code editing. You get a code editor, plus a compiler, a debugger, and more features like autocomplete, highlighting, and syntax checking, to name a few.
Also, there are other features that may not be directly aimed towards your code but that help in the big picture of creating applications. For example, a dependency manager so that you can import and use third-party libraries; integration with source control like Git; in some cases, a performance profiler so that you know how your application is behaving in terms of memory, CPU, or I/O; and functionality to help you deploy your application.
Below I am going give a brief introduction to available Python code editors.
Available Code Editors for Python
Let me give you an overview of some of the available code editors for Python.
Since code is mainly text, you can use something basic like Notepad. You don’t get many features like syntax highlighting, autocomplete, snippets, or many more, but it gets the job done.
On the downside, it may be a bit inconvenient when you’re working on a project that has many files. Switching from one window to another will be quite annoying.
There are other code editors that solve the problem of switching between windows, like Notepad++, which has tabs. You can keep your files open and switch from one to the other within the same window. For your information, Notepad++ has been voted several times in the past as one of the most used code editors in Windows, given some of its extensibility capabilities.
If you are a windows user, it is highly likely that you open code files, configuration files, XML files, or JSON files in Notepad++ from time to time.
And going along the same lines, there are certain code editors that you may have used in a terminal but that not everyone knows that you can use them also in windows like gVim, or the graphical version of Vim. You can use a mouse to access many of its functionalities, but you still get the power of vi. vi, or Vim, is a touch choice for developers worldwide, and in some cases, it is one of the tools that is usually more easily available.
Once I mention vi, I need to also bring forward Emacs, which is a family of text editors that are quite famous for their extensibility. The most popular one being GNU Emacs, whose tag line is, “the extensible, self-documenting text editor. “
Emacs is quite powerful. It has thousands of built-in commands and has been available for quite a long time. The original Emacs was written in the 1970s, and Python is supported as part of the base distribution with Python mode.
Nano is a text editor that is quite lightweight and functional that runs in a command line environment. Sometimes, a simple code editor is all you need. Nano may not be the first choice for many, but it is there in case you need it.
It is available by default in some platforms, like in Linux or macOS, although it may not be as straightforward to get with Windows.
Nano applies syntax highlighting, which is good. However, the fact that it is available in multiple platforms does not mean that it will be configured and will run exactly the same in all of them, especially with different versions. If you move over to macOS, it may be configured a bit differently, but that should also not be a big deal.
And next on the list, we have vi from a terminal. I can use vi to open a Python program and start coding. Personally, I end up using vi not only for coding, but also for configuration changes quite frequently, especially when I have to SSH into a server, SSH meaning that I have to connect remotely, be it in the cloud or on premise.
Next in line we have Sublime Text, which, as they put it, it is a sophisticated text editor for code, markup, and prose. Sublime Text, which you can find at www.sublimetext.com, is cross platform.
Sublime Text runs on Windows, Mac, and Linux, something that’s quite convenient, given that Python also runs on all three operating systems, making it easy to test your application from the same source code editor.
Getting Sublime is not that hard. You can start by going to the download page, which auto detects the platform you are in. If you are on Windows it’ll say Download for Windows and if you are on Mac, It’ll say Download for Mac..
And with Linux, you can use one of the Linux repositories, depending on your distribution. For example, it can be ‘apt’ or ‘yum’.
Note that, Sublime Text is not free. You have to pay a license to use it. It has syntax highlighting and compatible with many language grammars, with Python being one of the supported languages.
Atom is a hackable text editor for the 21st century which you can find at atom.io. One of the main features of Atom is how well it integrates with source control, particularly with GitHub. This is no surprise, as it was developed and it is maintained by GitHub themselves.
Apart from this, it has many of the features that you would expect from a code editor, including being cross platform; it works in macOS, Windows, and Linux, it has autocompletion; a flexible interface, that besides tabs, it lets you split into multiple panes. It also has a built-in package manager that lets you find that package that you need to extend Atom. And those are just some of the features.
Atom is open source. You can find it in github.com/atom. Moreover, there’s some interesting information, like the fact that Atom is built on Electron, which is a framework also built by GitHub. It allows creating desktop applications using web technologies.
Visual Studio Code
Visual Studio Code is an open source code editor built on Electron same like Atom. It was created by Microsoft which is free, and extensible. It is a great choice for working with Python, and installing it is easy. You can get it at code.visualstudio.com.
Just a quick note, Visual Studio Code is different from Visual Studio, which is the integrated development environment of choice for developers that use Microsoft technologies like .NET.