The strongest Python development environment PyCharm's recommendation

I have been in Python for about 7 years now and have changed various development environments such as PyScripter and Vim. I assert that ** PyCharm is the strongest Python development environment **.

687474703a2f2f692e696d6775722e636f6d2f4b4f5273636b562e706e67.png PyCharm Home Page

Developed by JetBrains of IntelliJ IDEA, it recently announced Gogland, an IDE for the Go language. The operating environment is Windows / OS X / Linux multi-platform. There are free and paid versions of PyCharm, but for normal development, the free version is more than enough.

Let me show you how useful PyCharm is.

Real-time code check and fix function

PyCharm checks the code in real time (using PyFlakes), but Vim can do the same, so it's not new. The great thing about PyCharm is that it has a feature that ** fixes warnings properly **.

For example, suppose you write code like this:

member = {}
member["name"] = "Tim"
member["age"] = 32
member["sex"] = "men"

PyCharm warns you with a wavy line in the bad part.


I don't know what you're saying, but let's move the cursor to the wavy line and press "Alt + Enter" (for Windows).


It will suggest a solution to the warning, so select "Replace dictionary creation".

members = {"name": "Tim", "age": 32, "sex": "men"}

Redundant variable declarations and initializations over multiple lines have been optimized for one sentence. As you can see, PyCharm can do something about it by pressing "Alt + Enter" when you are in trouble.

Another thing that is sober and convenient is that it has an English dictionary that points out misspellings of words and mistakes in plural forms **.


The figure above is an example where it is pointed out that the plural form of "property" is to be written as "propertys" (correctly "properties"). Thanks to this warning feature, I haven't committed several embarrassing English word mistakes.

If you want to inspect all the codes at once, you can select "Code"-> "Inspect Code ..." from the menu to inspect all the codes at once.


Powerful type hinting

Python is, needless to say, a dynamically typed language. It is also a fact that completion is difficult to work because it is a dynamically typed language, and an error occurs because an invalid type is specified for the argument. PyCharm allows type hinting to pre-type check ** like a statically typed language.

For example, suppose you have defined a function `get_digit``` that finds the digits of a number, the argument accepts ```int``` or float```. If `` str or `` `list is specified as an argument, TypeError will occur.

def get_digit(x):
    digit = 0
    while x > 0:
        x //= 10
        digit += 1
    return digit

Execution result

>>> 3
>>> 3
>>> TypeError

Let's describe PyCharm type hinting. If you move the cursor to an argument or function and press "Alt + Enter", a template for type hinting will be generated, so it is very easy to describe.


The code that describes type hinting is below.

def get_digit(x):
    :type x: int or float
    :rtype: int
    digit = 0
    while x > 0:
        x //= 10
        digit += 1
    return digit

After writing type hinting, I get a warning when I try to pass a string to `` `get_digit```.


I don't write function comments, but only type hinting. (A spirit that does not require comments if the naming is appropriate)

By the way, if you want to set type hinting for class members, write as follows.

class A(object):
    :type name: basestring
    :type description: basestring or None
    def __init__(self, name): = name
        self.description = None

With PyCharm, Python becomes ** the strongest language for dynamically and statically typed languages **. It also supports type annotations introduced in Python 3.5.

For more information on type hinting, see Jet Brains Help below. Type Hinting in PyCharm