Tools to develop Python code#

Introduction#

We’ve seen that Python is characterized by:

  • Most of the times interpreted

  • Dynamically strongly typed

  • Indentation defines the blocks

  • Style coding is important: pep8

Important

  • Dynamic languages are strong thanks to tooling and testing.

  • Without good tooling and testing, they are really BAD!

  • USE good developer tools! The first step is to use good Python editors.

Developer tools and good practices#

  • Linters, formatters and type checkers

  • Documentation and comments

  • Testing

Editors#

The editor can and has to help you!!

  • syntax colouring

  • automatic indentation

  • code analysis (code analysis, for example powered by pyflakes and pylint)

  • introspection capabilities such as code completion

There are many editors designed for Python development. Among the open-source editors, we can mention

  • emacs and vim (historical editors, great but somewhat difficult to use and need to be configured)

  • VSCode/VSCodium

  • Spyder

  • JupyterLab

We can also mention PyCharm, which is proprietary.

Warning

For Python development, try to avoid editors not designed for Python development or badly configured.

More or less all these editors need to be configured. For example, for VSCode, do not forget to install the extensions provided by ms-python. Most of these editor have sync feature so that you can share your configuration between different computers.

Exercise 7 (PEP8 checker with Spyder editor)

In Spyder, open the file ../common/examples/wrong.py and see what append.

Activate the “Real time code style analysis (PEP 8)” (Preferences -> Editor -> Code Introspection/Analysis).

Correct the file to remove the warnings.

Where and how to find and get help#

Todo

  • Editors / IDE (JupyterLab, VSCode/VSCodium and Spyder)

    • basis

    • main extensions for Python

    • debug

    • sync configuration

    • overall comparison between these IDEs