MCPcopy Create free account
hub / github.com/dabeaz/python-cookbook / CodeAnalyzer

Class CodeAnalyzer

src/9/parsing_and_analyzing_python_source/example1.py:3–14  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1import ast
2
3class CodeAnalyzer(ast.NodeVisitor):
4 def __init__(self):
5 self.loaded = set()
6 self.stored = set()
7 self.deleted = set()
8 def visit_Name(self, node):
9 if isinstance(node.ctx, ast.Load):
10 self.loaded.add(node.id)
11 elif isinstance(node.ctx, ast.Store):
12 self.stored.add(node.id)
13 elif isinstance(node.ctx, ast.Del):
14 self.deleted.add(node.id)
15
16# Sample usage
17if __name__ == '__main__':

Callers 1

example1.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected