Pythonists使用哪些代码编辑器?

Not into Python? Prefer Ruby instead? Here are the most popular editors and IDEs for Rubyists.

不进Python吗? 更喜欢Ruby? 以下是针对Rubyists的最受欢迎的编辑器IDE

So, you’ve decided to learn Python? Great! Python is a really interesting programming language, that has been described as a descendent of ABC that appeals to Unix/C developers. And you can’t go wrong with a language named after Monty Python!

所以,您决定学习Python? 大! Python是一种非常有趣的编程语言,它被描述为ABC的后代,吸引了Unix / C开发人员。 而且,以Monty Python命名的语言不会错!

So yes, you have many exciting things waiting for you.

是的,您有许多激动人心的事情在等着您。

But one of the first things you’ll need to do is pick an editor you’ll use to write your Python program. Well, here comes the confusion. You’re faced with tons of editors out there, each with a community trying to get you attracted to using that editor. “Use vim!” “Use Emacs!” “Use Sublime Text!”

但是,您需要做的第一件事就是选择一个用于编写Python程序的编辑器。 好吧,混乱来了。 您面临着众多的编辑器,每个编辑器都有一个社区,试图吸引您使用该编辑器。 “使用vim!” “使用Emacs!” “使用崇高文字!”

You recoil in fear… what if you make the wrong choice?

您因恐惧而退缩……如果您选择错误,该怎么办?

This feeling inspired me to interview Pythonists about their favorite Python editor. This will show which editors are used by the most Pythonists, and from there we can try to work out why. My hope is that it’ll serve as a guide for newcomers to Python, or even for those already working with Python.

这种感觉启发了我采访Python专家,了解他们最喜欢的Python编辑器。 这将显示大多数Python专家使用的编辑器,然后我们可以尝试找出原因。 我希望它可以作为Python新手甚至是已经使用Python的新手的指南。

I’ll start by discussing the most popular editors, then take a look at the advantages (and disadvantages) of the winner, before moving on to looking at how to install it onto your system.

我将首先讨论最受欢迎的编辑器,然后研究获胜者的优点(和缺点),然后再研究如何将其安装到系统上。

该调查 (The Survey)

I spoke to 100 Pythonists, who brought up the following editors (presented here in order of popularity):

我与100位Python专家进行了交谈,他们带来了以下编辑器(按受欢迎程度列出):

  1. Sublime Text

    崇高文字
  2. Vim

    Vim
  3. Emacs

    埃马克斯
  4. Notepad++

    记事本++
  5. TextWrangler

    文字牧马人
  6. IDLE

  7. Atom

    原子
  8. Aquamacs

    阿夸马克斯
  9. GNU Nano

    GNU纳米
  10. Kate

    凯特
  11. gedit

    Gedit

Sublime Text was by far the most preferred editor, used by 45% of the interviewees. The charts below tell the tale:

迄今为止,Sublime Text是最受欢迎的编辑器,被45%的受访者使用。 下面的图表讲述了这个故事:

Fig.1
Fig.2

From the figures above, we can see Sublime Text rules as the favorite Python editor from the sample I have interviewed. This seems to go hand in hand with Sublime Text’s slogan: The text editor you’ll fall in love with.

从上图中,我们可以看到Sublime Text规则是我采访过的示例中最喜欢的Python编辑器。 这似乎与Sublime Text的口号齐头并进: 您会爱上的文本编辑器

Sublime Text的优势 (Sublime Text’s Advantages)

So what makes Sublime Text so special?

那么,什么使Sublime Text如此特别?

Like others, I use Sublime for my Python work. I like the features mentioned in this post about Sublime Text. Briefly, these are:

像其他人一样,我将Sublime用于我的Python工作。 我喜欢这篇关于Sublime Text的文章中提到的功能。 简单来说,这些是:

  • Packages: Sublime Text comes with a fully-featured package manager that helps the programmer to discover, install, update, and remove packages for Sublime Text.

    软件包 :Sublime Text带有功能齐全的软件包管理器 ,可帮助程序员发现,安装,更新和删除Sublime Text的软件包。

  • Macros: Instead of retyping simple strings of text, you can simply record macros and create a keyboard shortcut to output that text into your document.

    :您无需记录简单的文本字符串,而只需记录并创建键盘快捷键即可将文本输出到文档中。

  • Colors: In Sublime Text, you can quickly pick colors for the interface and text.

    颜色 :在Sublime Text中,您可以快速选择界面和文本的颜色

Other useful features for Sublime Text, as mentioned in this SitePoint Smackdown post, are as follows:

本SitePoint Smackdown文章所述,Sublime Text的其他有用功能如下:

  • Comprehensive language support with TextMate-compatible grammar

    兼容TextMate的语法提供全面的语言支持

  • “Goto Anything” quick navigation to locate files and code

    “ Goto Anything”快速导航以查找文件和代码

  • A command palette to access all features

    用于访问所有功能的命令面板

  • Extensive customization, great themes and numerous plugins

    广泛的自定义,出色的主题和众多插件

Sublime Text的缺点 (Sublime Text’s Shortcomings)

However, Sublime Text still needs some improvements to become a better editor for Python.

但是,Sublime Text仍需要进行一些改进才能成为Python更好的编辑器。

Here are some ways Sublime Text could be improved to work better with Python:

以下是Sublime Text可以改进以更好地与Python配合使用的一些方法:

  • In Sublime Text, some deep language specific integration features such as static analysis and refactoring, also available through plugins, are not that polished.

    在崇高的文本,一些深层次的语言特定的集成功能,如静态分析和重构,也可通过插件,是不是抛光

  • Dynamic analysis of code and autocomplete need to be enhanced.

    代码的动态分析和自动完成需要增强

  • Sublime Text could be made more friendly to new Python programmers. For example, if one needs to configure the application’s preferences, this is done by writing/editing lines of code. This is something a new programmer may feel uncomfortable attempting.

    Sublime Text可以使新Python程序员更加友好。 例如,如果需要配置应用程序的首选项 ,可以通过编写/编辑代码行来完成。 这是新程序员可能会感到不舒服的尝试。

  • As a continuation to the previous point, Sublime Text needs to be simplified a bit, as it has a steep learning curve, and plugins need to be simplified, since they can be confusing.

    作为上一点的延续,Sublime Text需要稍微简化 ,因为它具有陡峭的学习曲线,并且插件也需要简化,因为它们可能会造成混淆。

  • While the app can be equipped with impressive features, these have to be installed separately, and some of them are not free.

    该应用程序可以配备令人印象深刻的功能 ,但这些功能必须单独安装,其中一些并非免费。

  • Sublime Text is inaccessible via the terminal.

    无法通过终端访问 Sublime Text。

如何为Python设置Sublime文本 (How to Set Up Sublime Text for Python)

So, you want to give it a try? In this section, I’ll show you how to setup Sublime Text to work with Python. I will be demonstrating this on a Microsoft Windows 8.1 machine. If you want to do that on a MAC OS X machine, you can follow this tutorial, and on an Ubuntu machine, you can refer to this thread.

那么,您想尝试一下吗? 在本节中,我将向您展示如何设置Sublime Text以与Python一起使用。 我将在Microsoft Windows 8.1计算机上进行演示 。 如果要在MAC OS X机器上执行此操作,可以遵循本教程 ,在Ubuntu机器上,可以参考此线程

Let’s get started.

让我们开始吧。

安装Python (Installing Python)

Download Python from here. I will download Python 3.4.2. This will be an msi file. Thus, the file you will get downloaded is python-3.4.2.msi. Run the installer, for which it will display the wizard shown in the figure below:

这里下载Python。 我将下载Python 3.4.2。 这将是一个msi文件。 因此,您将下载的文件是python-3.4.2.msi 。 运行安装程序,安装程序将显示下图所示的向导:

pythonInstaller

Navigate through the steps until you finish the setup wizard. You’ll notice that Python was installed in C:\Python34\, if you kept the default location.

浏览各个步骤,直到完成安装向导。 如果保留默认位置,您会注意到Python安装在C:\Python34\

安装Cygwin (Installing Cygwin)

The next step is to setup Cygwin, a tool for providing Windows with similar functionality to a Linux distribution. If you’re on a 32-bit Windows, download the setup file from here. If you are on a 64-bit Windows, download the setup file from here. After you download the appropriate setup file, run that file, for which you will get the following start page in the wizard:

下一步是设置Cygwin ,该工具可为Windows提供与Linux发行版相似的功能。 如果您使用的是32位Windows,请从此处下载设置文件。 如果您使用的是64位Windows,请从此处下载安装文件。 下载适当的安装文件后,运行该文件,您将在向导中获得以下开始页面:

cygwinInstaller

Keep navigating through the installer until you reach the following step:

继续浏览安装程序,直到完成以下步骤:

cygwinInstaller-2

In this step, we’ll be installing three software packages: curl, git, and openssh. For this, let’s use the Search box. For example, for curl, type the word in the search box, but, be careful, don’t hit the enter key, as this will continue the Cygwin installation. When you type curl in the search box, you should get something like the following:

在此步骤中,我们将安装三个软件包: curlgitopenssh 。 为此,让我们使用“ Search框。 例如,对于curl ,在搜索框中键入单词,但是要小心,不要按Enter键,因为这将继续Cygwin的安装。 在搜索框中键入curl时,您应该得到如下内容:

cygwinInstaller-3

What we want to do now is install each of the packages above. Click on the + sign. You will notice skip, click on skip, so you get the latest version number of the package, which we want to install. In this case, you should get something similar to the following:

我们现在要做的是安装上面的每个软件包。 单击+号。 您会注意到skip ,单击skip ,这样您会获得我们要安装的软件包的最新版本号。 在这种情况下,您应该获得类似于以下内容的信息:

cygwinInstaller-4

Click the Next button, and wait until the packages are downloaded. This might take some time to finish.

单击“ Next按钮,然后等待直到软件包被下载。 这可能需要一些时间才能完成。

Do the same for the other two packages, git and openssh.

对其他两个软件包gitopenssh

After you finish, you should get a Cygwin shortcut at your desktop, like this:

完成后,您应该在桌面上获得Cygwin快捷方式,如下所示:

cygwinIcon

Through this terminal, you’ll be running your Python code, in addition to accessing the packages installed above. If you double click the icon shortcut, you should get something like the below image:

通过该终端,除了访问上面安装的软件包之外,您还将运行Python代码。 如果双击图标快捷方式,您将获得下图所示的内容:

bash

To make sure that the packages were installed, and get an idea of their locations, we will use the which command, as follows:

为了确保已安装软件包,并了解它们的位置,我们将使用which命令,如下所示:

confirm

I was able to install Python through Cygwin using the following step (notice ‘Python’ at the end):

我可以使用以下步骤通过Cygwin安装Python(最后注意“ Python”):

python

If you happen to miss this step, or you want Cygwin to find and use the Python version you installed above, you can issue this command in the terminal:

如果您碰巧错过了此步骤,或者希望Cygwin查找并使用上面安装的Python版本,则可以在终端中发出以下命令:

$ echo "PATH=\$PATH:/cygdrive/c/Python34" >> .bash_profile

安装Sublime文字 (Installing Sublime Text)

Now, for the easiest part. To install Sublime Text, go to the Sublime Text homepage, download, and set it up. Very easy!

现在,最简单的部分。 要安装Sublime Text,请转至Sublime Text 主页 ,下载并进行设置。 好简单!

测试您的安装 (Test Your Installation)

At this point of the tutorial, let’s test if our setup works, and we’re ready to use Sublime Text to work with Python.

在本教程的这一点上,让我们测试一下我们的设置是否可行,并且我们准备使用Sublime Text与Python一起使用。

Open Sublime Text, and type this line of code:

打开Sublime Text,然后输入以下代码行:

print("Hello Python!)

Choose File -> Save. In the Save As dialog box, choose where to save the file, name the file, and in Save as type:, choose Python. For instance, this is what I chose:

选择File -> Save 。 在“ Save As对话框中,选择保存文件的位置,命名文件,然后在“ Save as type:选择“ Python”。 例如,这就是我选择的内容:

saveAs

Now, open the terminal (Cygwin icon shortcut), and navigate to where you saved your Python file. In my case, it was on the Desktop. In my case, the file path would like like the following:

现在,打开终端(Cygwin图标快捷方式),然后导航到保存Python文件的位置。 就我而言,它在Desktop 。 就我而言,文件路径如下所示:

filePath

Finally, type the following command in the terminal to run the Python program:

最后,在终端中键入以下命令以运行Python程序:

python hello

In which case, you should get the following output:

在这种情况下,您应该获得以下输出:

output

You now have everything setup, and ready to delve through the Python world with Sublime Text! One of the first things you should do now is check out this collection of plugins for Python development with Sublime Text.

现在,您已完成所有设置,并准备通过Sublime Text深入Python世界! 您现在应该做的第一件事就是查看 Sublime Text开发Python 插件集

结论 (Conclusion)

While Sublime Text has a commanding lead in numbers, that’s but one consideration. There are many popular editors, and it may not be right for every Pythonist. Nevertheless, it’s always good to know how the majority handle their projects, and there is something to be said for using a popular app or technology.

尽管Sublime Text在数字方面占主导地位,但这只是一个考虑因素。 有很多受欢迎的编辑器,可能不是每个Python专家都适合。 尽管如此,了解大多数人如何处理他们的项目总是一件好事,并且使用流行的应用程序或技术要说些什么。

What is your favorite Python editor? How do you set it up for working productively?

您最喜欢的Python编辑器是什么? 您如何设置它以提高工作效率?

翻译自: https://www.sitepoint.com/which-code-editors-do-pythonists-use/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值