Real Python: Python IDEs and Code Editors (Guide)

综合技术 Real Python (源链)

Writing Python using IDLE or the Python Shell is great for simple things, but those tools quickly turn larger programming projects into frustrating pits of despair. Using an IDE, or even just a good dedicated code editor, makes coding fun—but which one?

Fear not, Gentle Reader! We are here to help explain and demystify the myriad of choices available to you. We can’t pick what works best for you and your process, but we can explain the pros and cons of each and help you make an informed decision.

To make things easier, we’ll break our list into two broad categories tools—those built exclusive for Python development, and those built for general development we can use for Python. We’ll call out some Why’s and Why Not’s for each. Lastly, none of these are mutually exclusive, so you can try them out on your own with very little penalty.

But first…

What Is an IDE and a Code Editor?

An IDE (or Integrated Development Environment) is a program dedicated to software development. As the name implies, IDEs integrate several tools specifically designed for software development. These tools usually include an editor tailored to handling code (for example, syntax highlighting and auto-completion); build, execution, and debugging tools; and some form of source control.

Most IDEs support many different programming languages and contain many more features, and therefore can be large, take time to download and install, and require advanced knowledge to use properly.

In contrast, a dedicated code editor can be as simple as a text editor with syntax highlighting and code formatting capabilities. Most good code editors can execute code and control a debugger, and the very best interact with source control systems as well. Compared to an IDE, a good dedicated code editor is usually smaller and quicker, but often less feature rich.

Requirements for a Good Python Coding Environment

So what things do we really need in a coding environment? Feature lists vary from app to app, but there are a core set of features which makes coding easier:

  • Save and reload code files
    If an IDE or editor won’t let you save your work and reopen everything later, in the same state it was in when you left, it’s not much of an IDE.
  • Run code from within the environment
    Similarly, if you have to drop out of the editor to run your Python code, then it’s not much more than a simple text editor.
  • Debugging support
    Being able to step through your code as it runs is a core feature of all IDEs and most good code editors.
  • Syntax highlighting
    Being able to quickly spot keywords, variables, and symbols on your code makes reading and understanding code much easier.
  • Automatic code formatting
    Any editor or IDE worth it’s salt will recognize the colon at the end of a while or for statement, and know the next line should be indented.

Of course, there are lots of other feaures you might want (like source code control, an extension model, build and test tools, language help, etc.), but they work work support the core features.

With these features in mind, let’s take a look at some general purpose tools we can use for Python development.

General Editors and IDEs With Python Support

Eclipse + PyDev

Category:IDE

Website: www.eclipse.org

Python tools:PyDev, www.pydev.org

If you’ve spent any amount of time in the open-source community, you’ve heard about Eclipse. Available for Linux, Windows, and OS X at, Eclipse the de facto open-source IDE for Java development. It has a rich marketplace of extensions and add-ons, which makes Eclipse useful for a wide range of development activities.

One such extension is PyDev, which enables Python debugging, code completion, and an interactive Python console. Installing PyDev into Eclipse is easy—from Eclipse, select Help, Eclipse Marketplace, then search for PyDev. Click Install, and restart Eclipse if necessary.

Why:If you’ve already got Eclipse installed, adding PyDev is quick and easy. The learning curve for PyDev is non-existant for the experienced Eclipse developer.

Why Not:If you’re just starting out with Python, or with software development in general, Eclipse can be a lot to handle. Remember when I said IDEs are larger and need more knowledge to use properly? Eclipse is all that and a bag of (micro)chips.

Sublime Text

Category:Code Editor

Website: http://www.sublimetext.com

Written by a Google engineer with a dream for a better text editor, Sublime Text is an extremely popular code editor. Supported on all platforms, Sublime Text has built in support for Python code editing, and a rich set of extensions (called packages) which extend the syntax and editing features.

Installing additional Python packages can be tricky – all Sublime Text packages are written in Python itself, and installing community packages often require you to execute Python scripts directly in Sublime Text.

WHY

Sublime Text has a great following in the community. As a code editor, alone, Sublime Text is fast, small, and well supported.

WHY NOTSublime Text is not free, although you can use the evaluation version for an indefinite period of time. Installing extensions can be tricky, and there’s no direct support for executing or debugging code from within the editor.

To make the most of your Sublime Text setup, read our Python + Sublime Text setup guide and consider our in-depth video course that shows you how to craft an effective Python development setup with Sublime Text 3.

Atom

Category:Code Editor

Website: https://atom.io/

Available on all platforms, Atom is billed as the “hackable text editor for the 21st Century”. With a sleek interface, file system browser, and marketplace for extensions, open-source Atom is built using Electron , a framework for creating desktop applications using JavaScript, HTML, and CSS. Python language support is provided by an extension which can installed when Atom is running.

WHY

Broad support on all platforms, thanks to Electron. Atom is small, and downloads and loads fast.

WHY NOT

Build and debugging support aren’t built-in, but are community provided add-ons. Because Atom is built on Electron, it’s always running in a JavaScript process, and not as a native application.

GNU Emacs

Category:Code Editor

Website: https://www.gnu.org/software/emacs/

Back before the iPhone vs Android war, before the Linux vs Windows war, even before PC vs Mac war, there was the Editor War , with GNU Emacs as one of the combatants. Billed as “the extensible, customizable, self-documenting, real-time display editor”, GNU Emacs has been around almost as long as UNIX, and has a fervent following.

Always free and available on every platform (in one form or another), GNU Emacs uses a form of the powerful Lisp programming language for customization, and various customization scripts exist for Python development.

WHY

You know Emacs, you use Emacs, you love Emacs. Lisp is a second language, and you know the power it gives you means you can do anything.

WHY NOT

Customization means writing (or copy/pasting) Lisp code into various script files. If it’s not already provided, you may have to learn Lisp to figure out how to do it.

Plus, you know that Emacs would be a great operating system, if it only had a good text editor…

Be sure to consult our Python + Emacs setup guide to make the most of this setup.

VI/VIM

Category:Code Editor

Website: https://www.vim.org/

On the other side of the Text Editor War sits VI (aka VIM). Included by default on almost every UNIX system and Mac OS X, VI has an equally fervent following. VI and VIM are modal editors, separating the viewing of a file from the editing of a file. VIM includes many improvements on the original VI, including an extensibility model and in-place code building. VIMScripts are available for various Python development tasks.

WHY

You know VI, you use VI, you love VI. VIMScripts don’t scare you, and you know you bend it to your will.

WHY NOT

Like Emacs, you’re not comfortable finding or writing your own scripts to enable Python development, and your’re not sure how a modal editor is supposed to work.

Plus, you know that VI would be a great text editor, if only it had a decent operating system.

If you’re going with this combination, check out our Python + VIM setup guide with tips and plugin recommendations.

Visual Studio

Category:IDE

Website: https://www.visualstudio.com/vs/

Python tools: Python Tools for Visual Studio , aka PVTS

Built by Microsoft, Visual Studio is a full-featured IDE, in many ways comparable to Eclipse. Built for Windows and Mac OS only, VS comes in both free (Community) and paid (Professional and Enterprise) versions. Visual Studio enables development for a variety of platforms, and comes with it’s own marketplace for extensions.

Python Tools for Visual Studio (aka PTVS) enables Python coding in Visual Studio, and enables Intellisense for Python, debugging, and other tools.

WHY

Like Eclipse, if you already have Visual Studio installed for other development activities, adding PTVS is quick and easy.

WHY NOT

Just like Eclipse, Visual Studio is a big download for just Python. Plus, if you’re on Linux, you’re out of luck – there is no Visual Studio install for that platform.

Visual Studio Code

Category:Code Editor

Website: https://code.visualstudio.com/

Python tools: https://marketplace.visualstudio.com/items?itemName=ms-python.python

Not to be confused with full Visual Studio, Visual Studio Code (aka VS Code) is a full-featured code editor available for Linux, Mac OS X, and Windows platforms. Small and light-weight, but full-featured, VS Code is open-source , extensible , and configurable for almost any task. Like Atom, VS Code is built on Electron, so it has the same advantages and disadvantages that brings.

Installing Python support in VS Code is very easy – the Marketplace is a quick button click away. Search for Python, click Install, and restart if necessary. VS Code will recognize your Python installation and libraries automatically.

WHY

Thanks to Electron, VS Code is available on every platform, surprisingly full-featured despite having a small footprint, and open-source.

WHY NOT

Electron means VS Code is not a native app. Plus, some people may have principled reasons to not use Microsoft resources.

Python Specific Editors and IDEs

PyCharm

Category:IDE

Website: https://www.jetbrains.com/pycharm/

One of the best (and only) full-featured, dedicated IDEs for Python is PyCharm. Available in both paid (Professional) and free open-source (Community) editions, PyCharm installs quickly and easily on Windows, Mac OS X, and Linux platforms.

Out of the box, PyCharm supports Python development directly – open a new file and start writing code. You can run and debug Python directly inside PyCharm, and it has support for source control and projects.

WHY

It’s the de facto Python IDE environment, with tons of support and a supportive community. It edits, runs, and debugs Python out of the box.

WHY NOT

PyCharm can be slow to load, and the default settings may need tweaking for existing projects.

Thonny

Category:IDE

Website: http://thonny.org/

A recent addition to the Python IDE family, Thonny is billed as an IDE for beginners. Written and maintained by the Institute of Computer Science at the University of Tartu in Estonia, Thonny is available for all major platforms, with installation instructions on the site.

By default, Thonny installs with it’s own bundled version of Python, so you don’t need to install anything else new. More experienced users may need to tweak this setting so already installed libraries are found and used.

WHY

You’re a beginning Python user, and want an IDE that’s ready to roll.

WHY NOT

More experienced Python developers will find Thonny too basic for most uses, and the built-in interpreter is something to work around, not with. Plus, as a new tool, there may be issues you find which may not have immediate solutions.

So Which One Is Right for You?

Only you can decide that, but here are some basic recommendations:

  • New Python developers should try solutions with as few customizations as possible. The less that gets in the way, the better.
  • If you use text editors for other tasks (like web pages or documentation), look for code editor solutions.
  • If you’re already developing other software, you may find it easier to add Python capabilities to your existing toolset.

您可能感兴趣的

markdown代码高亮,支持标记语言的列表 在markdown编辑时,我们经常需要引入一段代码,此时若果代码能高亮显示, markdown代码高亮 界面就会非常友好。 使用前:public static void main(String[] args){ System.out.println(“Hel...
Python中解码decode()与编码encode()与错误处理UnicodeDecodeErro... 编码方法encoding( ) 描述 encode() 方法以指定的编码格式编码字符串,默认编码为 'utf-8'。将字符串由string类型变成bytes类型。 对应的解码方法:bytes decode()方法。 语法 ...
Python Decorator(装饰器) 今天来说说 Python 里的装饰器 (decorator)。它不难,但却几乎是 “精通” Python 的路上的第一道关卡。让我们来看看它到底是什么东西,为什么我们需要它。 手写装饰器 现在我们要写一个函数: def add(x, y=10): retur...
Quantitative Value Investing Strategy In Python By Ishan Shah Value investment traces its origin back to Security Analysis and The Intelligent Investor books by Benjamin Graham in which he ...
A Gentle Introduction to Normality Tests in Python An important decision point when working with a sample of data is whether to use parametric or nonparametric statistical methods. Parametric stat...
责编内容来自:Real Python (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » Real Python: Python IDEs and Code Editors (Guide)



专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录