I have a function in python
def func(x):
# x is int
for cell in list1:
# gets each cell
print cell
how to use eval to calculate new string?
Any ideas please?
Thanks
I have a function in python
def func(x):
# x is int
for cell in list1:
# gets each cell
print cell
how to use eval to calculate new string?
Any ideas please?
Thanks
You don't want to substitute. You want to evaluate the expression. I would suggest you try something like this:
variables = { x: 900 }
cell = 'x+3'
result = eval(cell, locals=variables)
This will evaluate the cell
expression using python syntax. As long as your cell formulas are simple enough, that will probably be okay. If you start trying to do Excel spreadsheet formulas, you will need to do a lot more work.