I'm solving some text2code problem for question-answering system and in the process I had the following question: Is it possible to run strings of code as complete code by passing arguments from the original environment? For example,I have these piece of code in str:
import module model=module(data,*args) And from base environment I want to do:
#for example args=[**some args**] data=pd.DataFrame() exec(string)(data=data,*args) For obvious reasons, transferring the data object using string.format() will not work. Standard unpacking using * does not work either, although, perhaps, I am doing something wrong.