various python utility functions and classes