I can get AST without comments using
import ast
module = ast.parse(open('/path/to/module.py').read())
Could you show an example of getting AST with preserved comments (and whitespace)?
The ast
module doesn't include comments. The tokenize
module can give you comments, but doesn't provide other program structure.