import main as m

import json
import argparse
import ast

parser = argparse.ArgumentParser()
parser.add_argument('operation')
parser.add_argument('func')
parser.add_argument('options')
args   = parser.parse_args()
operation = args.operation
func      = args.func

options   = json.JSONDecoder().decode(args.options)

def f(func):
    def inner(x):
        return eval(func)
    return inner

func = f(func)

if operation == 'minimize':
    results = m.minimize_scalar(func, options)

print json.JSONEncoder().encode(results)

@@ -9,16 +9,62 @@
 ain as m
+%0Afrom sympy.utilities.lambdify import lambdify
 %0A%0Aimport
@@ -356,16 +356,18 @@
 tions)%0A%0A
+# 
 def f(fu
@@ -371,16 +371,18 @@
 (func):%0A
+# 
     def 
@@ -391,16 +391,18 @@
 ner(x):%0A
+# 
         
@@ -419,20 +419,22 @@
 l(func)%0A
+#
     
+ 
 return i
@@ -439,16 +439,18 @@
  inner%0A%0A
+# 
 func = f
@@ -517,20 +517,35 @@
 _scalar(
+lambdify('x', 
 func
+)
 , option

Introduce lambdify rather than exec