Created
May 4, 2018 12:07
-
-
Save fmasanori/b00d12779d9b3f78e64716ae43ed7b2f to your computer and use it in GitHub Desktop.
AST42
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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