Generic python utilities