title: Converting a python numeric expression to LaTeX
body: <p>I need to  convert strings with valid python syntax such as:</p>
  
  <pre><code>'1+2**(x+y)'
  </code></pre>
  
  <p>and get the equivalent LaTeX:</p>
  
  <pre><code>$1+2^{x+y}$
  </code></pre>
  
  <p>I have tried sympy's latex function but it processes actual expression, rather than the string form of it:</p>
  
  <pre><code>&gt;&gt;&gt; latex(1+2**(x+y))
  '$1 + 2^{x + y}$'
  &gt;&gt;&gt; latex('1+2**(x+y)')
  '$1+2**(x+y)$'
  </code></pre>
  
  <p>but to even do this, it requires x and y to be declared as type "symbols".</p>
  
  <p>I want something more straight forward, preferably doable with the parser from the compiler module.</p>
  
  <pre><code>&gt;&gt;&gt; compiler.parse('1+2**(x+y)')
  Module(None, Stmt([Discard(Add((Const(1), Power((Const(2), Add((Name('x'), Name('y'))))))))]))
  </code></pre>
  
  <p>Last but not least, the why: I need to generate those latex snipptes so that I can show them in a webpage with mathjax.</p>