Python IDE: A few of the practical features in Pycharm

Source: Internet
Author: User
So far, I've been using eclipse for a few years now, and most of the time is spent writing python (installing the Pydev plugin) and C + + (installing the CDT plugin).

I recently heard from a good friend about Pycharm and its new free community Edition logr. My friend, who has been using eclipse for a long time, is also very pycharm, so I decided to try to use pycharm at least when I was working at home. So far, I have been deeply fond of it, even in my daily work with Pycharm (Community edition with Apache2 authorization).

I'll show you some of the things I'm surprised at when I'm using Pycharm.

Statement

I didn't mean to criticize eclipse or pydev, I used them for years, they were great! Please keep in mind that this is my personal experience and yours may be different.

Real-time comparison

Pycharm keeps track of the changes you make in a file by displaying a blue marker in the left column of the editor.

This is very handy, and I've been using the command "Compare against HEAD" in Eclipse to compare changes before and after a file.

In Pycharm, you can make a sweeping change to your changes. At the same time, clicking on that tag will show the previous content and a toolbar:

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

Compare Preview on Commit

In Eclipse, when you commit a change, a commit dialog box shows you the list of files that will be submitted.

You can double-click any of these to see the contrast of the changes: At this point, if you see something in the code that you want to change (such as a misspelled word, a

Missing documents, and so on), that's not good: you have to close everything (including the submission box with your well-written commit comment), find the annoying code, correct it, and then start over again.

Pycharm has the same features, but your changes are editable. I can hardly emphasize how great it is to fix those mistakes on the spot!

During the commit process, I can easily fix similar spelling mistakes like those above.

An additional benefit is that, regardless of the reason you closed the commit dialog, when you try to commit again, it retains those submission comments that you just filled out.

Check at Commit

During the commit process, we can also perform some other options before the actual commit, such as "optimize import (sort and remove unused imports)", check for items to be completed in the change collection, and so on.

An interesting place is the "Perform code analysis" that ...

Code review

You can have pycharm perform a "code review" operation in a file, directory, or entire project. It can be done without actually executing the program,

Identify problems and the corresponding improvements, such as type checking, static methods, violation of code specifications, and so on.

As explained in the previous section, this can also be done automatically at commit time in the file where the change occurred. This is the result of a file review:

For some of these review results, you can also apply a remediation recommendation. For example, we can choose the option to fix the "Function call can replaced with set literal ()" recommendation.

Pycharm will take this sentence:

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

Automatically replaced by:

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

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

Refactoring

I've been trying to rename a module, but I can't find it in the menu item ... F2 is useless.

Suddenly I notice the "refactoring/renaming" item below the file submenu and just want to ... Is it going to be it? Sure enough!

When you rename a module, Pycharm will ask you if you need to automatically modify all of the items associated with it. Blessed is it!

There are many other refactoring projects, but so far I haven't had the chance to try one by one.

Tips for outdated code and suggestions for improvement

Pycharm can tell you out-of-date structure blocks in your code and suggest some improvements. For example, I have code like the following:

With nested (open (filename1), open (filename2)) as (F1, F2): < code block >

Pycharm will clearly mark out the nested:

I'm using Python2.7, in fact you can use the nested context manager, but, alas, I have to support some of Python's older versions to keep the nested.

But Pycharm reminds me that this thing is cool in itself.

Task + Feature Branch

Like eclipse (requires Mylin support), Pycharm also supports task-based workflows (including task-aware contexts).

However Pycharm itself comes with a lot of directly available connectors (Github,mantis,jira,bugzilla, etc.).

And, when you start a task, it asks if you want to create a feature branch of that task, and the name of the branch can be configured.

This avoids the need to manually create a new branch, which is really cumbersome (get the ID of the task, choose the name, and so on).

This is an extra-penny.

Fast

I observed that pycharm scans the code much faster than eclipse when executing the automatic completion of the code, and does not interrupt your current work.

When you want to save a file, eclipse will prevent you from doing so because it is performing a task in the background, which is annoying ...

Quickly view documents

When you move your cursor over a function, method, class, or something, you get an option to navigate the quick document. Take a look:

As you can see, it will present a document description of the method in a pleasing format, and also hints at the type of the parameter from the Code usage instructions ... Even if the function doesn't have a corresponding document description, you'll get a description like this:

Very good!

Docutils Support

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

On the other hand, it also includes a very good rich text (translator Note: Rest is restructuredtexteditor) editor (more useful than Eclipse's IMHO):

Complete plug-in system

As far as my experience is, installing plugins in eclipse is a painful thing to do:

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

    • You do not have a single index, so you have to go online to find those plug-in source;

    • The system sometimes crashes because of the library's dependency problem, and I don't have the plugins I want (and others in the work have the same problem, and finally have to give up);

Pycharm's plugin experience is much smoother.

First, it's in a place where you think it might exist: just under "Settings":

You can easily browse plugins:

I quickly installed a markup editor (like rest), a plugin that temporarily holds snippets of code, allowing me to quickly clip from the text of the selection and preview the code, similar to Sublimetext, with a nice code look.

Conclusion

So far, that's all. I will try to show my friends all the things I think "see how cool It is". I use Pycharm for a short time, and if I find that there are more interesting things to write about, I will continue to write.

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

Related Article

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.