Search for random python program generator

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.

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!"

+5
source share
3 answers

A python random generator generator Google search included the Python random generator .

If you want to download the script, check out pyfuzz .

+3
source

.

, , , / , , , . , - , . . , .

, , - , Whigham CFG-GP. BNF-, . , , Python , . , - , .

, , python . , . GP , , , . , .

+2

I recommend PushGP . Here is a link to the python class.

0
source

All Articles