Pycharm usage tips (7) Some practical functions

Source: Internet
Author: User

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 use the following sentence ::

Copy codeThe Code is as follows:
Xtensions = set (['. avi', '.mp4', '. mpg', '.mkv'])

Automatically replaced:

Copy codeThe Code is as follows:
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:

Copy codeThe Code is as follows:
With nested (open (filename1), open (filename2) as (f1, f2 ):
<Code block>

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.














 

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.