misc generic tools and helpers in Python