Some useful Python codes