No, the ast module can only process Python code for the version of Python that it comes with. This is because under the hood, the same parser is used to compile Python code into byte code; the entire ast is module gives you the AST tree broker. This analyzer does not have backward compatibility mode.
You will need to implement your own parser if you want to parse various source codes from Python versions. This certainly means the path that Jedi (Python autocomplete library).
Looking at the SublimeCodeIntel packaging of CodeIntel2 , I see that this package bases its Python and Python 3 parsers on SilverCity , which has Python bindings. Perhaps this project will be a suitable starting point for your own.
source share