Fixing Python Generation Code