miscellaneous python utility functions