python utility functions