Skip to content

Instantly share code, notes, and snippets.

@zyga
Last active September 14, 2017 11:45
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 zyga/4989123 to your computer and use it in GitHub Desktop.
Save zyga/4989123 to your computer and use it in GitHub Desktop.
Experiment with python3 ast module
import ast
class Visitor(ast.NodeVisitor):
def __init__(self):
self._names_seen = set()
def visit_Name(self, node):
self._names_seen.add(node.id)
node = ast.parse("all(package.name not in ['plainbox', 'tuxracer'])")
v = Visitor()
v.visit(node)
print(v._names_seen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment