"Easy Python": lies, damned lies, and metaclasses

  • Author: Grigory Petrov, Maxim Danilov
  • https://2022.pycon.de/program/BG37DV/

  • Python often referred as simple, executable pseudocode.

  • But after initial code. Develoepers welcomed with
  • protocols, decorators, context managers, metaclasses and rest of the "real Python" shenanigans

What is complex code:

  1. Hard to understand
  2. Hard to maintain
  3. Hard to change
  4. Requires a lot of working memory.

Abstraction level in Python

  • Function
  • Class
  • Module

Features in python

1. Special syntax

  1. Walrus Operator
  2. Can be complex if used with list comprehension
  3. Function arguments etc.
  4. Argument separation
  5. Keyword only argument
  6. Positional argument
  7. Pattern matching

2. Python data mode.s

  • Has 125+ data models.

3. Scopes

  • Can have different blocks
  • local
  • non-local
  • global
  • builtin
  • inheritence
  • MRO
  • Context managers

4. Metaprogramming

  1. Decorators
  2. Metaclass

5. Dependency management

What is the solution?

  • Have guidelines for project.
  • Company follow strict guidelines