A Python program, in its basic form, is simply lines of text (code) saved in a file with a .py file extension. Python code can be written in something as basic as Notepad – but there’s no reason to put yourself through such an ordeal since there are much better options available. At it’s core, a code editor should provide a number of features that help a programmer create programs (Python scripts and modules, in our case). In most cases, python code editor allow the user to customize the program itself, to suit your needs and style.
What should you look for in a Python code editor?
- Ease of use
- Syntax highlighting
- Auto-indentation
- Tabbed views
- Line numbering
- Ability to customize the look and feel of the editor
- Availability of add-ons
Take a look at the following example:
So, not only is the code easier to read in the editor (Sublime Text) on the top (due to the syntax highlighting and line numbering), but it’s also identifying three simple errors, one of which is a show-stopper. (Can you figure out which one?) Meanwhile, the editor (Notepad) at the bottom does not display the errors and is hard on the eyes since it’s black and while.
Which editor should I use?
One of the most popular code editors is Sublime Text 3 (shown above). It is powerful, cross-platform, and free to try out.
Be sure to support the project by purchasing a license if you continue to use it.
If you want something simpler, check out gedit, which is also cross-platform. Notepad++ is also a great editor, but it’s for Windows only. Both of these editors are free and although neither possesses the power of Sublime Text, they are still useful.
A third option is Vim, which is free and available for Mac, Linux, and Windows. Vim has a steep learning curve but it has a loyal user base. Steve Francia’s Vim Distribution is the best programming setup for Vim that I have ever seen.
I personally prefer Sublime Text 3. Check out the blog post Setting Up Sublime Text 3 for Full Stack Python Development to see how to customize it specifically for writing Python code.
Remember: There are many different options when it comes to code editors, both free and commercial. Do your research, and don’t be afraid to experiment! Just remember: an editor should help you adhere to Python coding standards, practices, and idioms…