Created
July 29, 2015 13:43
-
-
Save stuartmyles/9f1887f3f7f9c88e0c61 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
# Use ast to generate an abstract syntax tree to assign an empty tuple to a variable named "nothing" | |
# i.e. equivalent to | |
# nothing = () | |
import ast | |
emptyness = ast.Module(body=[ ast.Assign(targets = [ | |
ast.Name(id = 'nothing', ctx = ast.Store())], | |
value = ast.Tuple(elts=[], ctx = ast.Load())) | |
]) | |
ast.fix_missing_locations(emptyness) | |
co = compile(emptyness, "<ast>", "exec") | |
exec(co) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment