title: Python | How to convert ast expression to string back
body: <p>I need to modify math expression from </p>
  
  <p><code>wave_y + .3 * sin(time * .788) + .005 * (frame % 3)</code> </p>
  
  <p>to </p>
  
  <p><code>wave_y + .3 * sin(time * .788) + .005 * fmodf(frame, 3)</code></p>
  
  <p>To do this I write own Transformator</p>
  
  <pre><code>class PercentToFmodTransformer(ast.NodeTransformer):
      def visit_BinOp(self, node):
          if type(node.op).__name__ == 'Mod':
              result = ast.Call()
              result.func = ast.Name(id='fmodf', ctx=ast.Load())
              result.args = [node.left, node.right]
              result.keywords = []
              result.starargs = None
              result.kwargs = None
  
              return result
          else:
              return ast.NodeTransformer.generic_visit(self, node)
  </code></pre>
  
  <p>After transformation I have <code>Expression</code> </p>
  
  <pre><code>Expression(
  body=BinOp(
      left=BinOp(
          left=Name(id='wave_y', ctx=Load()), 
          op=Add(), 
          right=BinOp(
              left=Num(n=0.3), 
              op=Mult(), 
              right=Call(
                  func=Name(id='sin', ctx=Load()), 
                  args=[BinOp(left=Name(id='time', ctx=Load()), op=Mult(), right=Num(n=0.788))], 
                  keywords=[], 
                  starargs=None, 
                  kwargs=None)
              )
          ), 
          op=Add(), 
          right=BinOp(
              left=Num(n=0.005), 
              op=Mult(), 
              right=Call(
                  func=Name(id='fmodf', ctx=Load()), 
                  args=[Num(n=3), Name(id='frame', ctx=Load())], 
                  keywords=[], 
                  starargs=None, 
                  kwargs=None
              )
          )
      )
  )
  </code></pre>
  
  <p>But I don't know how to print it in human-readable format. Can this be done my some default function Or I should write own visitor for this?</p>
  
  <p>P.S. I don't ask to write the implementation of this Visitor for me, I just want to know is possible to do this by inbox API.  </p>