Created
July 22, 2015 20:55
-
-
Save stuartmyles/15c73a9b8e17ec5dff9c to your computer and use it in GitHub Desktop.
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 | |
class Greeter: | |
def __init__(self): | |
#m = "Hello world!" | |
assignment = ast.Module(body=[ ast.Assign(targets = [ | |
ast.Name(id = 'm', ctx = ast.Store())], | |
value = ast.Str(s="Hello world!")) | |
]) | |
ast.fix_missing_locations(assignment) | |
co = compile(assignment, "<ast>", "exec") | |
exec(co) | |
self.message = m |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment