Skip to content

Instantly share code, notes, and snippets.

@milesrout
Last active April 16, 2017 03:39
Show Gist options
  • Save milesrout/5538168d1a6df041bf444fe7a2927a0b to your computer and use it in GitHub Desktop.
Save milesrout/5538168d1a6df041bf444fe7a2927a0b to your computer and use it in GitHub Desktop.
import x
from y import x
from a.z.b import q
from .....a import q
from x import (a, b, c, d)
import a, b, z, d, fe, q
import a.ce, efa.f, ae.e
def hello(world):
def foo():
pass; \
pass
if 0 < 0.05 <= 1:
print('foo', 5)
pass
foo()
def foo():
print_hello = (def(a, b, c):
a; b; c
print('Hello',
(def(): \
(print(1, 2, 3), print(a, b, c))
),
'World')
)
ast:
[
"Statements",
{
"stmts": [
[
"Statements",
{
"stmts": [
[
"ImportStatement",
{
"names": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "x"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"FromImportStatement",
{
"name": [
[
"IdExpression",
{
"name": "y"
}
]
],
"dots": 0,
"what": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "x"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"FromImportStatement",
{
"name": [
[
"IdExpression",
{
"name": "a"
}
],
[
"IdExpression",
{
"name": "z"
}
],
[
"IdExpression",
{
"name": "b"
}
]
],
"dots": 0,
"what": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "q"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"FromImportStatement",
{
"name": [
[
"IdExpression",
{
"name": "a"
}
]
],
"dots": 5,
"what": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "q"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"FromImportStatement",
{
"name": [
[
"IdExpression",
{
"name": "x"
}
]
],
"dots": 0,
"what": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "a"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "b"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "c"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "d"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"ImportStatement",
{
"names": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "a"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "b"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "z"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "d"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "fe"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "q"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"ImportStatement",
{
"names": [
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "a"
}
],
[
"IdExpression",
{
"name": "ce"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "efa"
}
],
[
"IdExpression",
{
"name": "f"
}
]
],
"alias": null
}
],
[
"ImportName",
{
"name": [
[
"IdExpression",
{
"name": "ae"
}
],
[
"IdExpression",
{
"name": "e"
}
]
],
"alias": null
}
]
]
}
]
]
}
],
[
"FunctionDefinition",
{
"name": [
"id",
"hello"
],
"params": [
[
"Param",
{
"name": [
"id",
"world"
],
"annotation": null,
"default": null
}
]
],
"suite": [
"Statements",
{
"stmts": [
[
"FunctionDefinition",
{
"name": [
"id",
"foo"
],
"params": [],
"suite": [
"Statements",
{
"stmts": [
[
"Statements",
{
"stmts": [
[
"PassStatement",
{}
],
[
"PassStatement",
{}
]
]
}
],
[
"IfElifElseStatement",
{
"branches": [
[
"IfBranch",
{
"cond": [
"ComparisonChain",
{
"input": [
[
"IntExpression",
{
"base": "octal_int",
"expr": "0"
}
],
"lt",
[
"PowerExpression",
{
"expr": [
"FloatExpression",
{
"format": "pointfloat",
"expr": "0.05"
}
],
"exponent": [
"IntExpression",
{
"base": "decimal_int",
"expr": "1"
}
]
}
]
],
"result": [
[
[
"IntExpression",
{
"base": "octal_int",
"expr": "0"
}
],
"lt",
[
"PowerExpression",
{
"expr": [
"FloatExpression",
{
"format": "pointfloat",
"expr": "0.05"
}
],
"exponent": [
"IntExpression",
{
"base": "decimal_int",
"expr": "1"
}
]
}
]
]
]
}
],
"suite": [
"Statements",
{
"stmts": [
[
"Statements",
{
"stmts": [
[
[
"AtomExpression",
{
"atom": [
"IdExpression",
{
"name": "print"
}
],
"trailers": [
[
"CallTrailer",
{
"args": [
[
"StringExpression",
{
"type": "s_string",
"unparsed": "'foo'"
}
],
[
"IntExpression",
{
"base": "decimal_int",
"expr": "5"
}
]
]
}
]
]
}
]
]
]
}
]
]
}
]
}
]
]
}
],
[
"Statements",
{
"stmts": [
[
"PassStatement",
{}
]
]
}
]
]
}
],
"return_annotation": null
}
],
[
"Statements",
{
"stmts": [
[
[
"AtomExpression",
{
"atom": [
"IdExpression",
{
"name": "foo"
}
],
"trailers": [
[
"CallTrailer",
{
"args": []
}
]
]
}
]
]
]
}
]
]
}
],
"return_annotation": null
}
],
[
"FunctionDefinition",
{
"name": [
"id",
"foo"
],
"params": [],
"suite": [
"Statements",
{
"stmts": [
[
"Statements",
{
"stmts": [
[
"ChainedAssignment",
{
"assignees": [
[
[
"IdExpression",
{
"name": "print_hello"
}
]
],
[
[
"TupleLiteral",
{
"exprs": [
[
"FunctionExpression",
{
"params": [
[
"Param",
{
"name": [
"id",
"a"
],
"annotation": null,
"default": null
}
],
[
"Param",
{
"name": [
"id",
"b"
],
"annotation": null,
"default": null
}
],
[
"Param",
{
"name": [
"id",
"c"
],
"annotation": null,
"default": null
}
]
],
"suite": [
"Statements",
{
"stmts": [
[
"Statements",
{
"stmts": [
[
[
"IdExpression",
{
"name": "a"
}
]
],
[
[
"IdExpression",
{
"name": "b"
}
]
],
[
[
"IdExpression",
{
"name": "c"
}
]
]
]
}
],
[
"Statements",
{
"stmts": [
[
[
"AtomExpression",
{
"atom": [
"IdExpression",
{
"name": "print"
}
],
"trailers": [
[
"CallTrailer",
{
"args": [
[
"StringExpression",
{
"type": "s_string",
"unparsed": "'Hello'"
}
],
[
"TupleLiteral",
{
"exprs": [
[
"FunctionExpression",
{
"params": [],
"suite": [
"Statements",
{
"stmts": [
[
[
"TupleLiteral",
{
"exprs": [
[
"AtomExpression",
{
"atom": [
"IdExpression",
{
"name": "print"
}
],
"trailers": [
[
"CallTrailer",
{
"args": [
[
"IntExpression",
{
"base": "decimal_int",
"expr": "1"
}
],
[
"IntExpression",
{
"base": "decimal_int",
"expr": "2"
}
],
[
"IntExpression",
{
"base": "decimal_int",
"expr": "3"
}
]
]
}
]
]
}
],
[
"AtomExpression",
{
"atom": [
"IdExpression",
{
"name": "print"
}
],
"trailers": [
[
"CallTrailer",
{
"args": [
[
"IdExpression",
{
"name": "a"
}
],
[
"IdExpression",
{
"name": "b"
}
],
[
"IdExpression",
{
"name": "c"
}
]
]
}
]
]
}
]
]
}
]
]
]
}
],
"return_annotation": null
}
]
]
}
],
[
"StringExpression",
{
"type": "s_string",
"unparsed": "'World'"
}
]
]
}
]
]
}
]
]
]
}
]
]
}
],
"return_annotation": null
}
]
]
}
]
]
]
}
]
]
}
]
]
}
],
"return_annotation": null
}
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment