Python port of underscore.js