Today I spent about half an hour trying to figure out a mysterious bug in my Python code. The reason turned out to be quite unexpected, so I decided to write up a small post about it both as a reminder to my future self and as an cautionary tale to other unsuspecting victims.
This is a minimal reproduction of the bug:
class Node(object):
def __init__(self, children={}):
"""
By default children is an empty dict, but you can set
children directly by supplying them as a value to the keyword argument.