PythonIDE: practical functions of PyCharm in fine count

Source: Internet
Author: User
So far, I have been using Eclipse for some years. most of the time I have spent writing Python (installing the Pydev plug-in) and C ++ (installing the CDT plug-in ). Recently I heard about PyCharm and its new free community version logr from a friend. My friend has been using Eclipse for a long time and is full of praise for PyCharm, so I decided to try to use PyCharm at least when working at home. So far, I have already liked it, and even use PyCharm in my daily work (Community Edition uses Apache2 authorization ). I will introduce some of the surprises I have been surprised when using PyCharm. so far, I have been using Eclipse for some years, most of the time is used to write Python (install the Pydev plug-in) and C ++ (install the CDT plug-in ).

Recently I heard about PyCharm and its new free community version logr from a friend. My friend has been using Eclipse for a long time and is full of praise for PyCharm, so I decided to try to use PyCharm at least when working at home. So far, I have already liked it, and even use PyCharm in my daily work (Community Edition uses Apache2 authorization ).

Here I will introduce some things that surprised me when I use PyCharm.

Statement

I have no intention of criticizing Eclipse or PyDev. I have used them for many years and they are great! Remember, this is my personal experience and you may be different.

Real-Time comparison

PyCharm keeps track of your changes in a file in real time by displaying a blue tag on the left bar of the editor.

This is very convenient. I used the "Compare against HEAD" command in Eclipse to Compare the changes before and after a file.

In PyCharm, you can view your changes at a glance. At the same time, click the tag to display the previous content and a toolbar:

You can easily roll back these changes, view these changes in a detailed dialog box, or paste the previous text to the clipboard.

Comparison preview at submission

In Eclipse, when you submit changes, a submit dialog box is displayed to show you the list of files to be submitted.

You can double-click any item to view the comparison of the changes: at this time, if you see some places in the code that you want to modify (such as a misspelled word, a paragraph

The missing documents, and so on, are annoying: you must close everything (including the submission box with your well-written comments) and find the annoying code, correct the rules and start from the beginning.

PyCharm has the same features, but your changes are editable. I simply cannot emphasize how great it is to correct those mistakes on the spot!

During the submission process, I can easily fix spelling errors similar to those above.

One additional benefit is that, no matter why you close the submit dialog box, when you try to submit again, it will keep the comments you just filled in.

Check when submitting

During the submission process, we can also execute other options before the actual submission, such as "optimizing the import (sorting and removing unused imports)", check the items to be completed in the change set.

One interesting thing is that "execute code analysis...

Code review

You can have PyCharm perform the "code review" operation in a file, directory, or entire project. It does not need to actually execute the program,

Identify existing problems and corresponding improvement methods, such as type checks, static methods, and code violations.

As explained in the previous section, this can also be automatically completed in the modified file at the time of submission. This is the result of a document review:

For some of the review results, you can also apply a repair suggestion. For example, for the "Function call can be replaced with set literal ()" suggestion, we can select the appropriate options to fix it.

PyCharm will put this sentence:

extensions = set(['.avi', '.mp4', '.mpg', '.mkv'])

Automatically replaced:

extensions = {'.avi', '.mp4', '.mpg', '.mkv'}

You can close any review you don't want, including at the project level.

Reconstruction

I 've been trying to rename a module, but I can't find that item in the menu... F2 does not help.

Suddenly I noticed the "refactoring/rename" item under the sub-menu of the file... Will it be? That's it!

When you rename a module, PyCharm will ask if you need to automatically modify all associated projects. Blessed!

There are many other refactoring projects, but so far I have no chance to try them one by one.

Tips for outdated code and suggestions for improvement

PyCharm can tell you the outdated structure blocks in the code and provide some suggestions for improvement. For example, I have the following code:

With nested (open (filename1), open (filename2) as (f1, f2 ):
 <代码块>

PyCharm will clearly mark the nested:

I use Python2.7. In fact, you can use the nested Context manager. However, alas, I have to support some old versions of python and keep the nested.

But PyCharm reminded me that this is a cool thing.

Task + feature Branch

Like Eclipse (Mylin support is required), PyCharm also supports task-based workflows (including task-aware context ).

However, PyCharm itself comes with many direct available connectors (GitHub, Mantis, Jira, Bugzilla, and so on ).

When you start a task, it will ask if you want to create a feature branch for that task. the branch name can be configured.

This avoids the need to manually create a new branch, and this operation is indeed cumbersome (get the task ID, select the name, and so on ).

This is a plus item.

Fast

I have observed that the scanning speed of PyCharm code is much faster than that of Eclipse when code execution is completed automatically without interrupting your current work.

When you want to save a file, Eclipse will prevent you from doing this because it is executing a task in the background, which is annoying...

Quick Document Viewing

When you move the cursor to a function, method, class, or something else, you will get an option to browse the "quick document". Take a look:

As you can see, it will show the document description of the method in a pleasing format, and prompt the parameter type from the code instructions... Even if the function does not have the corresponding documentation, you will still get a description like the following:

Good!

Docutils support

PyCharm also includes first-class support for doctils, which makes it easy to directly generate documents from the integrated development environment.

On the other hand, it also includes a very good rich text editor (Translator's note: ReST is reStructuredTexteditor) (more useful than Eclipse's IMHO ):

Complete plug-in system

Based on my experience, installing plug-ins in Eclipse is quite painful:

  • It's hard to find where you want to go (tip: help/install new software ...);

  • You don't have a single index, so you have to go online to find those plug-in sources;

  • The system sometimes crashes due to library dependency issues. as a result, I didn't install the plug-ins I wanted (other people at work also encountered this problem and finally had to give up );

PyCharm plug-in experience is much smoother.

First, it is located in a place where you think it may exist: in the "Settings" column:

You can easily browse the plug-in:

I quickly installed a tag editor (like ReST), a plug-in that temporarily stores code snippets, allowing me to directly cut and paste the selected text and preview the code, similar to SublimeText, it also uses a beautiful code appearance.

Conclusion

So far. I will try my best to show my friends what I think is "How cool. I used PyCharm for a short time. if I find that there are more interesting things worth writing another article, I will continue to write.

Original article: Bruno Oliveira translation: Bole online-Gao Lei

The above is the Python IDE: detailed description of the practical functions in PyCharm. For more information, see other related articles in the first PHP community!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.