Pycharm Experience (vii) Introduction to some practical functions _python

Source: Internet
Author: User

Real-time comparisons

Pycharm keep track of the changes you make in a file, by displaying a blue mark in the left-hand column of the editor.



This is 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 have a glance at your changes. Also, clicking on the 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.

Comparison preview when submitting
In Eclipse, when you submit a change, a submission dialog box shows you the list of files that will be submitted.

You can double-click on any of these to see how the changes are compared: At this point, if you see something in the code that you want to modify (for example, a misspelled word, a

Missing documents, and so on), that's a bad thing: you have to close everything (including the submission box with your carefully written submissions), find the annoying code, correct it, and start over again.

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

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

An added bonus is that no matter what the reason you shut down the submit dialog, when you try to submit again, it retains the submissions you just filled out.

Check at time of submission
During the commit process, we can also perform other options, such as "Optimizing the import (sorting and removing unused imports)", checking for pending items in the change set, and so on, before the actual submission.

One interesting place is the "Execute Code Analysis" ...

Code review
You can have pycharm perform a "code review" operation in a file, directory, or entire project. It will, without the actual execution of the program,

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

As explained in the previous section, this can also be done automatically in the file that was changed when you submitted it. This is a document after a review of the results

For some of these reviews, you can also apply a fix proposal. For example, for the recommendation "Function call can is replaced with set literal ()", we can choose the appropriate option to fix it.

Pycharm will say:

Copy Code code as follows:

Xtensions = Set (['. avi ', '. mp4 ', '. mpg ', '. mkv '])

Automatically replaced by:

Copy Code code as follows:

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

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

I've been trying to rename a module, and I can't find that item in the menu item ... F2 also no avail.

Suddenly I noticed the "Refactor/rename" item under the File submenu, and I thought ... Would it be it? That's right!

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

There are a lot of other refactoring projects, but so far I haven't had a chance to try one by one.
Tips for outdated code and suggestions for improvement

Pycharm can tell you the outdated structure blocks inside the code and make some suggestions for improvement. For example, I have code like the following paragraph:

Copy Code code as follows:

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

Pycharm will clearly mark out the nested:

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

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

Task + Attribute Branch
Like eclipse (requiring Mylin support), Pycharm also supports task-based workflows, including task-aware contexts.

However, Pycharm itself brings a number of directly available connectors (Github,mantis,jira,bugzilla, etc.).

Also, when you open a task, it asks you if you want to create an attribute 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 tedious (get the ID of the task, select the name, and so on).

This is the addition of the sub-item.

Fast
I have observed that Pycharm scans the code faster than eclipse when executing the code, and does not interrupt your current job.

When you want to save a file, eclipse will prevent you from doing so because it is performing a task backstage, how annoying ...

Quickly view documents
When you move the cursor over a function, method, class, or whatever, you get an option to browse the quick document. Take a look at:

As you can see, it shows the document description of the method in a pleasing format and prompts the type of the parameter from the Code usage instructions ... Even if the function does not have a corresponding document description, you will get a description like the following:

Very good!

Docutils Support
Pycharm also includes best-in-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 (much more useful than Eclipse's IMHO):

The Perfect plug-in system
With my experience, installing plug-ins in eclipse is a painful thing to do:

It's hard to find where you want to go (hint: Help/install new software ...) );
You do not have a single index, so you have to go online to find the source of those plug-ins;
The system sometimes crashes because of the dependencies of the library, and I don't have the plugins I want (there are other people in the job who have the same problem and finally have to give up);
The Pycharm plug-in 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 tag editor (like rest), a plug-in that temporarily stores snippets of code that let me quickly clip from the selected text and preview the code like Sublimetext, with a nice code look.

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














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.