Skip to content

Instantly share code, notes, and snippets.

@tarmstrong
Created November 29, 2013 02:43
Show Gist options
  • Save tarmstrong/7700893 to your computer and use it in GitHub Desktop.
Save tarmstrong/7700893 to your computer and use it in GitHub Desktop.
ghgghughghghghghghghghghghg
import lib2to3.pygram
import lib2to3.pgen2.driver as driver
class Tree(object):
def __init__(self, n):
self.n = n
self.used_names = set()
def __getitem__(self, idx):
return self.n[idx]
def blaconvert(g, n):
return Tree(n)
d = driver.Driver(lib2to3.pygram.python_grammar, blaconvert)
result = d.parse_string('a = 10\nclass Taco(object):\n def __init__(self):\n self.x = 10\n\n def bla(self):\n self.y = 2\n\n')
print result[0]
print result[1]
print [i[2] for i in result[3][1][3]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment