Last active
September 14, 2017 11:45
-
-
Save zyga/4989123 to your computer and use it in GitHub Desktop.
Experiment with python3 ast module
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 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