Some useful functions for python