I would like to assemble Python 'ast.Module' objects inside of Wolfram Language and then submit them to Python via e.g. ExternalEvaluate["exec(astObject)"].
The Python ast, parse, eval, exec and compile functions can all operate on 'ast.Module' objects, either outputting them or taking them as inputs. However I don't know how I might assemble this object and send it over ExternalEvaluate.
I am trying to programmatically generate Python code on the Wolfram Language side (for a genetic algorithm) and then submit it to Python for evaluation. I could assemble Python code strings, but then I have to handle all of the indentation, which seems like a pain.
How can one create arbitrary Python objects on the Wolfram Language side?
B
Here is a description of the objects: https://greentreesnakes.readthedocs.io/en/latest/tofrom.html