how to evaluate a ast tree and change Add to Multiply ?
meInvent bbird
jobmattcon at gmail.com
Wed Oct 12 05:55:54 EDT 2016
i just expect to
rewrite + become multiply
by edit the example in the link provided
but search no examples about this,
feel unknown about args and keywords etc,
do not know how to write this
ast.Call(func=ast.Name(id='Add', ctx=ast.Load()),
args=[node], keywords=[])
On Wednesday, October 12, 2016 at 5:53:42 PM UTC+8, meInvent bbird wrote:
> i use example here
>
> http://greentreesnakes.readthedocs.io/en/latest/examples.html
>
>
>
>
> On Wednesday, October 12, 2016 at 5:47:12 PM UTC+8, Chris Angelico wrote:
> > On Wed, Oct 12, 2016 at 8:32 PM, meInvent bbird <jobmattcon at gmail.com> wrote:
> > > class ChangeAddtoMultiply(ast.NodeTransformer):
> > > """Wraps all integers in a call to Integer()"""
> > > def visit_Num(self, node):
> > > if isinstance(node.n, int):
> > > return ast.Call(func=ast.Name(id='Add', ctx=ast.Load()),
> > > args=[node], keywords=[])
> > > return node
> > >
> > >
> >
> > Your class name, docstring, and functionality are all different, and
> > you have given no explanation of what you want us to do. I can't read
> > minds quite that well.
> >
> > ChrisA
More information about the Python-list
mailing list