update function to generate python script