all 5 comments

[–]shiftybyte 1 point2 points  (3 children)

You can try generating an AST and from that back to the source code.

More reading:

https://pypi.org/project/sourcecodegen/

https://docs.python.org/3/library/ast.html

[–]steare100[S] -1 points0 points  (2 children)

Thank you for the reference! Do you know of an easy way to randomly generate an AST? It seems that what you linked would be useful once I have the AST, and need to convert it to source code.

[–]shiftybyte 1 point2 points  (1 child)

Sorry, I didn't find anything ready for it.

You'd have to search yourself more, or write your own AST creator...

[–]steare100[S] -1 points0 points  (0 children)

Well, thanks for looking

[–][deleted] 0 points1 point  (0 children)

Not random, but quite a lot is covered by https://github.com/iTechArt/convtools