General python utility functions