GithubHelp home page GithubHelp logo

maligree / python-ast-explorer Goto Github PK

View Code? Open in Web Editor NEW
247.0 247.0 30.0 36 KB

The code behind python-ast-explorer.com

License: Apache License 2.0

Python 18.60% HTML 11.91% CSS 11.25% JavaScript 58.24%

python-ast-explorer's People

Contributors

maligree avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-ast-explorer's Issues

ast produced seems out of date w.r.t. module changes

for a simple example, the input

x.sort(reverse=True)

comes out as follows in the tool:

image

However, in the latest version of Python (3.8.1 as of this writing), the following AST is produced:

>>> ast.dump(ast.parse("x.sort(reverse=True)"))
"Module(body=[Expr(value=Call(func=Attribute(value=Name(id='x', ctx=Load()), attr='sort', ctx=Load()), args=[], keywords=[keyword(arg='reverse', value=Constant(value=True, kind=None))]))], type_ignores=[])"

That's a little hard to read, so let's look specifically at the keywords part:

keywords=[keyword(arg='reverse', value=Constant(value=True, kind=None))]

Here, the value of the keyword is an ast.Constant object, as opposed to the ast.Name object presented in the output of the tool. The documentation of the ast module is very sparse, so I'm not sure in what version this was introduced, but suffice it to say this is proof that the tool is out of date.

Very nice, but I see a problem

print(astor.dump_tree(ast.parse('5*c * (-1 + d)', mode='eval'))) is

Expression(
    body=BinOp(left=BinOp(left=Num(n=5), op=Mult, right=Name(id='c')),
        op=Mult,
        right=BinOp(left=UnaryOp(op=USub, operand=Num(n=1)), op=Add, right=Name(id='d'))))

but I don't see the UnaryOp at https://python-ast-explorer.com.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.