An annoying Python gotcha
Imagine you have this in mod.py:
Seems fine right? In fact, there's a nasty bug here. If I try to use this module in client.py like so:
mybar = bar()
Then you're likely to get an exception when the program exits. This is because Python, for some bizarre reason, Nones out the globals in mod.py when taking down the interpreter. The actual __del__ method can be called sometime after this, and it ends up trying None.cleanup(), with the resultant AttributeError. It seems extremely bizarre that it happens in this order, but it does (a real example).