Programma
Login

Python has a macro language: it's Python

A small but growing number of Python projects, including attrs, cattrs and incant, use Python to generate Python.

We will example concrete cases of code generation in these libraries and go over the ‘how’ and the ‘why’.

Abstract

Macros in mainstream languages are generally a tool for metaprogramming, probably the most famous examples being preprocessor directives in C and C++, and Rust macros.

Python has rich metaprogramming capabilities baked in through the compile and eval built-in functions, although a little care needs to be taken for the generated code to be debuggable and properly shown in track staces.

We will examine one concrete example of metaprogramming in each of the attrs, cattrs and incant libraries.

Speaker
Tin Tvrtkovic
Argomento
Python & Friends
Livello audience
Advanced
Lingua
Inglese
Durata
30 minuti
Speaker name:
Tin Tvrtkovic
Torna al programma
      Powered by Vercel Logo