Ask HN: What's your favorite Python quirk?

3 points by wampler ↗ HN
Any unusual or unexpected feature of the language

4 comments

[ 1.8 ms ] story [ 23.6 ms ] thread
Abusing locals() - learnt it from @jroller

def foo(): """ >>> foo() {'a': 1, 'c': 3, 'b': 2} """ a = 1 b = 2 c = 3 return locals()

My favorite quirk was deprecated.

Python 2.x

def function(a, (b, c)): # pattern extract matches a strictly two-elements

Python 3.x

def function(a, b_c): # not as clean, nor as expressive