nvbn / py-backwards

Python to python compiler that allows you to use Python 3.6 features in older versions.
306 stars 17 forks source link

Snippets #6

Closed nvbn closed 7 years ago

nvbn commented 7 years ago

Creating ast for code manually isn't easy and error prone, so it would be nice to implement something like snippets:

@snippet
def my_snippet(class_name, body):
    class class_name:  #  replace class_name with value of `class_name`
        extend(body)  # extend class body with `body`

    let(x)  # declare variable with unique name
    x = 10