python code, mainly for CCCma