From http://skien.cc/blog/2014/04/09/unpythonic-python/