Python Tricks #2: Emulating Switch/Case in Python

► Write Clean & Beautiful Python: https://dbader.org/pytricks-book Python doesn’t have switch/case statements so it’s often necessary to write long if/elif/e…

Similar

Nuitka Is a Python Compiler

Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.12. You feed it your Python app, it does a lot of clever things, and spits out an executable or... (more…)

Read more »

Python: default argument blunders

A few minutes ago a friend sent me the following code, and told me its misbehaving: def foo(l=[]): l.append("hello!") print(l) foo() foo() Instead of printing ["hello"] twice, it printed ["hello", "hello"]. Any ideas why? what's going on? I'll... (more…)

Read more »