Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Created May 4, 2018 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmasanori/b00d12779d9b3f78e64716ae43ed7b2f to your computer and use it in GitHub Desktop.
Save fmasanori/b00d12779d9b3f78e64716ae43ed7b2f to your computer and use it in GitHub Desktop.
AST42
import ast
import codegen
expr='''
def resposta():
print ('Alô Mundo')
'''
p = ast.parse(expr)
p.body[0].body = [ast.parse('return 42').body[0]]
print(codegen.to_source(p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment