Miscellaneous functions in Python