python - SymPy's Sympify Function Returns a String, Not a SymPy Object -


i have excel file 2 columns; first containing variable name, , second containing mathematical expression typed string. using python 2.7.12 , openpyxl 2.3.2, i'm importing data. string imported unicode default.

i create sympy object imported string perform operations on it. however, in case sympifying imported string returns string object, not sympy object. why this?

i expected behaviour (sympify returning sympy object) if instead hard-code string .py file.

this code illustrates:

from sympy import * import openpyxl  imported_data = openpyxl.load_workbook('sample_workbook.xlsx') data = imported_data.get_sheet_by_name('sheet1')  variable_name = data['a1'].value variable_value = data['b1'].value globals()[variable_name] = variable_value  x = symbols('x')  print(type(variable1))      # unicode string sympy_expr = sympify(variable1) print(type(sympy_expr))     # should sympy object, it's of type str 

workbook screenshot

workbook download


Comments