I am looking for a program that can generate random but valid python programs similar to
Random C program generator .
I tried to do this myself by providing random input to the python function tokenize.untokenize(), but of course most of the generated source code was an invalid program that I could interpret using eval(). So I would like to know if you either know a way to generate random but valid python programs (perhaps using a module ast?), Or if such a generator already exists.
tokenize.untokenize()
eval()
ast
EDIT: I want to use random python source code as a starting point for doing genetic programming using python. Therefore, I want to have a list of random programs, and then develop them to say that the program that returns "Hello World!"
A python random generator generator Google search included the Python random generator .
If you want to download the script, check out pyfuzz .
.
, , , / , , , . , - , . . , .
, , - , Whigham CFG-GP. BNF-, . , , Python , . , - , .
, , python . , . GP , , , . , .
I recommend PushGP . Here is a link to the python class.