The strongest Python integrated development environment PyCharm

The strongest Python integrated development environment PyCharm

A good IDE is the best teacher for learning a new language, so I think you should use it positively without being stingy. So, let's take a look at PyCharm, the strongest integrated development environment in Python. I think it's the most, so I'm writing it assuming WebApplication development with Django.

The functions and pricing system are as of December 15, 2015, PyCharm 5.0.2.

Overview

https://www.jetbrains.com/pycharm/

PyCharm is an IDE for Python from the Czech JetBrains s.r.o., which is famous for its high quality IDE. Works on Windows / OS X / Linux.

The JetBrains IDE is based on a Java IDE called IntelliJ IDEA PyCharm is developed as its Python plugin. We are also developing IDEs such as Ruby, PHP, JS, C ++, Objective-C / Swift.

Of these, PyCharm also comes with plugins related to Web development such as JS, CSS, HTML, so front-end development can be done in the same environment.

price

There is a paid Professional Edition and a free Community Edition. Community Edition has the same analysis mechanism of Python itself, but the above-mentioned plugins related to Web development and It should be noted that support for WebApplicationFramework and support for DB and SQL are omitted.

If you want to do web development, you should use Professional Edition.

There is a 30-day free trial, so give it a try.

Price structure

JetBrains products have a monthly / yearly subscription. The first year is the highest, and as you continue, it gradually becomes cheaper, and the amount is the same after the third year.

If you go to the purchase page, you will find two plans, a PyCharm-only plan and an All Products Pack that includes all IDEs in other languages, such as IntelliJ IDEA Ultimate. If you're developing iOS apps or using Ruby, PHP, Java, C ++, etc., the All Products Pack may be worth considering.

PyCharm comes with web-related features, so you don't need to buy WebStorm separately if you just want to write client-side code.

Installation

https://www.jetbrains.com/pycharm/download/ If you go to, you can download the image that suits your platform. All you have to do is install as instructed. The OS X version now comes with Java, so it works as is.

Project

スクリーンショット 2015-12-15 21.16.45.png

PyCharm manages code and settings in units called Project. It also supports project creation from the start screen, and it is also possible to load existing code or fetch it from VCS such as git.

In the following, we will introduce the recommended functions after that about the project settings.

スクリーンショット 2015-12-15 21.19.11.png

virtualenv management

In Python, the environment is often divided by virtualenv, so create and set the virtualenv environment for the created Porject. You can specify an existing virtualenv environment or create a new one when creating a project or in Preferences-> Project-> Project Interpreter. A list of installed libraries and the latest version are also displayed, which is convenient for batch checking of library updates.

スクリーンショット 2015-12-15 21.25.47.png

Raise PEP8 warning to warning

Since the warning level for PEP8 violation, which is the standard Python coding standard, is low, it is better to raise it by one level to make it a warning. There is no merit in violating PEP8 because the code of PEP8 violation causes nausea.

Raise the week warning to warning from Python-> PEP8 coding style violation in Preferences-> Editor-> Inspections. It's a good idea to raise the level of naming conversion violation below it as well.

スクリーンショット 2015-12-15 21.25.29.png

Change the check of the file encoding description

Python has a rule that indicates it at the beginning of the code if the file encoding is other than ascii. Add the following for its description style and check. Choose the Encoding comment format to your liking with Python-> File contains non-ASCII characters in Preferences-> Editor-> Inspections. It is also necessary if there is Japanese in the comment part, so it is good to put it in all files by default.

スクリーンショット 2015-12-15 21.25.25.png

Project Structure

You can add routes for search paths, templates, reference paths such as images, etc. If you can't get it out with code completion or jump to Template, check it.

Django Setting

When using Django, specify the location of settings and the location of the root as a Django project.

スクリーンショット 2015-12-15 21.26.28.png

Docstring format

The format used by Docstring. It works well when using commented type hinting. There is no problem if you select reStructuredText.

スクリーンショット 2015-12-15 22.37.51.png

Template Language

In addition to Django, it also supports Jinja2, Mako, Chameleon, etc. Let's specify the Template language to use.

スクリーンショット 2015-12-15 21.34.55.png

VCS

It supports VCS such as Git, Mercurial, Subversion. If it is set, changes can be confirmed from the editor, and partial restoration is also supported.

Even if the root of VCS is outside git submodule or Project, it will be recognized if you add the setting here.

Line number display, blank character display,

It can be found in Preferences-> Editor-> General-> Appearance. Overall, PyCharm's search is very good, so for now, just put it in the search box in the upper left and it will look nice.

スクリーンショット 2015-12-15 21.46.43.png

File template

You can specify the template when creating a new file. Preferences-> Editor-> File and Code Templates.

When using Python2.x, it is good to add the following two.

Absolute_import is confused by relative references if the import rule is Python 2.x, so let's only use absolute references. If you want to make a relative reference, you can explicitly describe it, and it is preferable to add it, so you do not have to worry about it. Same as the default behavior of Python3.x.

unicode_literals makes the default string type unicode. It's a bit long to explain, but it's also better to meet the behavior of Python3.x because it's less confusing.

python


from __future__ import absolute_import
from __future__ import unicode_literals

スクリーンショット 2015-12-15 21.25.35.png

(When writing code that supports multiple versions of Python)

You can select multiple versions to check with Python-> Code compatibility inspection in Preferences-> Editor-> Inspections. It is effective in library development. When writing code that works with 2.x series, it is better to write code that matches 3.4 or higher as much as possible.

スクリーンショット 2015-12-15 21.25.18.png

Function introduction

Search everywhere

It is a search bar that appears when you press Shift twice. It increments most things related to the Project, such as filenames, symbols, and actions. Method names and file names are searched by ignoring case and underscore delimiters, so it's nice to remember them. I think there are quite a lot of PyCharm users who depend on this.

スクリーンショット 2015-12-15 22.06.36.png

Code analysis

You can jump to the definition with Cmd + click or shortcut. It will look inside the library, so if you have any doubts about the behavior or arguments, you can easily read it. Even if the target cannot be specified by meta operation etc., the candidates are displayed, which makes code reading considerably easier.

In Project and Structure of ToolWindow, you can set the linkage with the specified editor side. You can specify the operation by selecting the following with the gear mark on the upper right. (Icon in Structure)

Auto Scroll to code
Display the file (line) selected in ToolWindow on the editor side
Auto Scroll from code
Display the file (line) displayed in the editor with ToolWindow

It is a good idea to set it to your liking. By the way, the path of the file that is currently in focus is shown at the top of the editor, so you can refer to the file in the directory in the middle from there.

スクリーンショット 2015-12-15 22.18.13.png

Code completion

General code completion will do everything you can. Moreover, it works with the same logic as Search everywhere, so I'm glad that it complements the latter half of the method name. To be honest, this is pretty strong.

Also, since it works even if you have not imported it, if you remember the class name or function name, you can write it for the time being, select a candidate with Alt + Enter, and automatically add an import statement.

There are various menus that come out from Alt + Enter where the warning is issued.

--Conversion of double quotes and single quotes. ――The automatic addition system gives various candidates depending on the context. The following is an example.

etc.

スクリーンショット 2015-12-15 22.13.53.png

TypeHinting

It's a type hint that has recently become a hot topic in Python3.5. PyCharm has been using commented TypeHinting for several years, and you can use TypeHinting for code completion and refactoring even if you are not using Python3.5.

If the type information is lost due to meta operations etc., add it with TypeHinting and the completion will be effective and argument errors will be found, so let's use it positively. I can't finish talking about TypeHinting, so I'll leave it to another article. The Syntax of TypeHinting that can be used in PyCharm is summarized below.

https://www.jetbrains.com/pycharm/help/type-hinting-in-pycharm.html

Database linkage

You can view / operate data from GUI by connecting to RDB such as MySQL. I mainly use SequelPro, so I don't use it much, but I think it will come in handy if I don't use ORM.

Supports Django / SQL Alchemy

Supports Django / SQL Alchemy ORM completion. These internal implementations have many meta operations, and although it is difficult to complete by simply analyzing static code, it is possible to complete or jump to the definition.

スクリーンショット 2015-12-15 22.42.38.png

Template & HTML & JS

You can seamlessly move from View to Template, and HTML / CSS / JS completion is perfect. It also analyzes the dependencies between Templates and paths such as images properly.

Since it also supports TypeScript and CoffeeScript, PyCharm is very useful even for clients who do not write server side.

スクリーンショット 2015-12-15 22.03.47.png

スクリーンショット 2015-12-15 22.04.00.png

debugger

PyCharm comes with a debugger that allows you to step, set breakpoints, stop variables, watch, and much more with a typical debugger. This debugger is also caught in the Template. Of course, step execution is possible. The stack trace in the Template is hard to see, so it's quite appreciated for complex Templates.

Remote debugger

You can use the debugger to follow the execution in the environment on the remote server by connecting with ssh. It is quite effective in investigating environment-specific problems.

Various other things

There are too many functions to write, but the accuracy of code analysis and completion is quite good, and the fact that all the functions are included from the beginning and there is no need to build an environment are the main reasons for recommending PyCharm. Once the indexing is done when the first project is loaded, search, replace, and automatic refactoring will work fairly fast, and they will all work together and be stress-free.

I often look at the comparison of only the function list, such as taking out only a part of the function and substituting it, but in the development environment, I think that it is most important that the code analysis and search that are used most are fast and comfortable. .. In that respect, PyCharm will give you an irreplaceable experience.

Recommended Posts

The strongest Python integrated development environment PyCharm
The strongest Python development environment PyCharm's recommendation
The strongest PySide / PyQt development environment is also PyCharm
Python development environment construction
About Python development environment
python2.7 development environment construction
Development environment in Python
Introduction to Python Let's prepare the development environment
Python + Anaconda + Pycharm environment construction
Organize your Python development environment
[ev3dev × Python] Build ev3dev development environment
[MEMO] [Development environment construction] Python
[For organizing] Python development environment
Unify the environment of the Python development team starting with Poetry
Commands often used in the development environment during Python implementation
How to get into the python development environment with Vagrant
Prepare Python development environment on Ubuntu
Integrated Development Environment (IDE) vs. Virtual environment
Prepare your first Python development environment
[Python3] Development environment construction << Windows edition >>
Python development environment options for May 2020
Python development environment construction on macOS
Vim + Python development environment setting memo
Install Python development environment on Windows 10
Emacs Python development environment construction memo
Prepare Python development environment with Atom
Prepare the development environment with anyenv
[No venv required] The strongest Python development environment created with Remote Containers [VS Code / Docker]
Continuation ・ Notes on preparing the Python development environment on Mac OS X
Using TensorFlow in the cloud integrated development environment Cloud9 ~ Basics of usage ~
Python (anaconda) development environment construction procedure (SpringToolsSuites) _2020.4
[Development environment] Python with Xcode [With screen transition]
Blender 2.82 or later + python development environment notes
About the virtual environment of python version 3.7
How to prepare Python development environment [Mac]
Python3 + venv + VSCode + macOS development environment construction
Prepare the development environment for keyhac for Mac
Build Python development environment (pythonz, virtualenv, direnv)
Building a Python development environment for AI development
Windows + gVim + Poetry python development environment construction
Create a Python development environment locally at the fastest speed (for beginners)
Prepare the development environment for Python on AWS Cloud9 (pip install & time change)
Prepare the execution environment of Python3 with Docker
Python environment construction
python environment settings
python windows environment
Building a Python environment with WLS2 + Anaconda + PyCharm
ffmpeg-Build a python environment and split the video
Create the strongest calculator environment with Sympy + Jupyter
Instantiation of the BOX development environment created earlier
[Python] Build a Django development environment with Docker
Install the python package in an offline environment
[Python] Web development preparation (building a virtual environment)
python environment construction
python development environment -use of pyenv and virtualenv-
Python --Environment construction
Arduino development on the command line: vim + platformio
Vim
vim
Vim + Python development environment setting memo
Set up a Python development environment on Marvericks
Python environment construction
python environment construction
Create a Python virtual development environment on Windows