YAPG implementation in Python