Python event algebra