astsearch icon indicating copy to clipboard operation
astsearch copied to clipboard

Python 2 compatibility

Open vfaronov opened this issue 8 years ago • 2 comments

This is such an obvious, obviously useful tool. I just had one of those semi-regular boats of “this tool must exist”, but this time I decided to actually search for it (or maybe the last time was before 2014), and sure enough you’ve already did it. Thank you!

If only this were Python 2 compatible (i.e. could parse Python 2 code, not necessarily run under Python 2), I would use it daily and tell all my friends about it. Hell, I’d wear a T-shirt with an ASTsearch logo on it.

Any idea how hard that would be? With some trivial changes I can make more than 50% of the tests pass under Python 2, but maybe those are the trivial 50% :)

vfaronov avatar Feb 03 '17 19:02 vfaronov

I'd guess not too hard. The biggest challenge would be the differences in AST structure - it changes a bit on each Python version. My docs here have some notes on the differences: http://greentreesnakes.readthedocs.io/en/latest/nodes.html

I'm pretty sure that the easiest way to let it parse Py2 code is to make it run under Py2 as well; the stdlib ast module it uses parses the version of Python that it's part of.

takluyver avatar Feb 03 '17 19:02 takluyver

I've been searching for something similar, this is all I've found for helping with Python 2 & 3 compatibility: https://github.com/serge-sans-paille/gast

alexbw avatar Mar 26 '17 16:03 alexbw