Did you know you can see how #Python parses your code? 🐍🤯

Breaking a .py file into a tree of "tokens" 🪙

python3 -m tokenize hi‍.py

Turning that into an "abstract syntax tree" 🎋

python3 -m ast hi‍.py

Then "disassembling" that to bytecode 🤖

python3 -m dis hi‍.py

When people say "comprehensions generate fewer operations than loops", they used dis.

I used the ast module when I made my undataclass script: https://www.pythonmorsels.com/undataclass/

More in this PyCascades talk: https://m.youtube.com/watch?v=RcGshw0tzoc&feature=youtu.be

Convert dataclass to non-dataclass

Want to see what code you'd need to write to recreate your dataclass without using the dataclass decorator? Try out this dataclass converter.

@treyhunner I've played with this a few years ago. Also, there are tools like Hylang and Macropy3, which use ast for building python code.