1.2. Development Environment

1.2.1. What is IDE?

  • Integrated Development Environment

  • Refactoring

  • Syntax autocompletion and highlighting

  • Type hinting and checking

  • VCS support

  • Virtualenv support

  • Debugging

  • Spell checking

  • Running code and inspections

  • File Scopes and views

  • Database explorer

  • Support for testing (doctest, unittest)

  • Jump to line in exceptions

1.2.2. How to Choose?

Python is about the source code, so in the end, it doesn't matter which IDE you choose. For editing plain source code you can also use Windows Notepad or VIM. However the bigger your program grows, and the more files it will contain, the harder it will be to maintain all that without proper tool. Good IDE will help you in refactoring, type hinting, debugging and working with Version Control System such as Git.

PyCharm has two versions: Community and Professional. For the regular development Community version will be more then enough. Professional version include better support for web-development (such as Java Script debugger, support for Django, FastAPI, and some other frameworks too). Database viewer is also available in paid version. Professional also better equipped for Data Science and Machine Learning. However as I said before you don't have to use all of that, because in the end the source code is what matters.

There is also a free alternative PyDev plugin for Eclipse.

1.2.3. Which One is the Best?

  1. PyCharm Professional (Not-free)

  2. PyCharm Community

  3. Jupyter Notebook

  4. Visual Studio Code

  5. PyDev

  6. Spyder

  7. Atom

  8. Vim

This are my preferences. Choosing best IDE is very opinionated.

1.2.4. Keyboard Shortcuts

Table 1.1. PyCharm Keyboard shortcuts

Key Combination

Action

ctrl + /

Comment multiple lines

alt + F12

Open Terminal

shift + F6

Refactor... Rename

tab

Indent (also used on multiple lines)

shift + tab

Un-indent (also used on multiple lines)

alt + 1

Show file drawer

Run

Show console

Actions

ctrl + g

Jump to line

ctrl + f

Search in file

ctrl + r

Replace in file

1.2.5. Assignments

Code 1.1. Solution
"""
* Assignment: About IDE Usage
* Complexity: easy
* Lines of code: 0 lines
* Time: 8 min

English:
    TODO: English Translation
    X. Run doctests - all must succeed

Polish:
    1. Jak zrobić w Twoim IDE:
        a. Run...
        b. Run in console
        c. Debug...
        d. Python Console
        e. Terminal
        f. Full Screen
        g. Distraction Free Mode
        h. Reformat Code
        i. Scope
    2. Jakie są skróty klawiszowe do poszczególnych opcji?
    3. Czym się różni `Run...` od `Debug...`?
    4. Czym się różni `Python Console` od `Terminal`
    5. Czym się różni `Distraction Free Mode` od `Full Screen`
    6. Ustaw Scope tak, aby ukryć katalog z Virtualenv
    7. Uruchom doctesty - wszystkie muszą się powieść
"""

Code 1.2. Solution
"""
* Assignment: About IDE Spellchecker
* Complexity: easy
* Lines of code: 0 lines
* Time: 5 min

English:
    1. Install `Hunspell` PyCharm plugin (File -> Settings -> Plugins -> Marketplace -> Hunspell)
    2. Download from https://github.com/LibreOffice/dictionaries/tree/master/en dictionary `.dic` and `.aff` for English language
        a. https://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_US.aff
        b. https://raw.githubusercontent.com/LibreOffice/dictionaries/master/en/en_US.dic
    3. Configure IDE to use that dictionary (File -> Settings -> Editor -> Spelling -> Add custom dictionary)
    4. Run doctests - all must succeed

Polish:
    1. Zainstaluj w PyCharm plugin `Hunspell` (File -> Settings -> Plugins -> Marketplace -> Hunspell)
    2. Pobierz z https://github.com/LibreOffice/dictionaries/tree/master/pl_PL słownik `.dic` oraz `.aff` dla języka polskiego
        a. https://raw.githubusercontent.com/LibreOffice/dictionaries/master/pl_PL/pl_PL.aff
        b. https://raw.githubusercontent.com/LibreOffice/dictionaries/master/pl_PL/pl_PL.dic
    3. Skonfiguruj IDE do korzystania z tego słownika (File -> Settings -> Editor -> Spelling -> Add custom dictionary)
    4. Uruchom doctesty - wszystkie muszą się powieść

Tests:
    >>> import sys; sys.tracebacklimit = 0

    TODO: Create doctest
"""