Some useful python functions