Mano machine implementation in Python