Review and improve python generation and representation