What I mean by the title is this for ex:
def write_to_file(*params):
    with open(path, 'r+', encoding="utf-8") as file:
        content = file.read()
        file.seek(0) 
        # custom code via func parameters to be executed
        # for example *params will be ["file.write("test" + '\n')", "]
        # and here will be like for loop that goes through the params ?
        # for code in params:
            #code.execute() ?
    
        file.truncate() 
Hopefully I explained it well, just wondering if you can do any of this.
// Edit (better explanation): I want to convert string into a code executable, "print(x)" -> print(x) that will be called in a function.
 
     
    