Transforming a str to an operator
Xavier Ho
contact at xavierho.com
Fri Aug 28 00:01:16 EDT 2009
On Fri, Aug 28, 2009 at 1:52 PM, Duke Normandin <dukeofperl at ml1.net> wrote:
> How do I convert the contents of "op" from a string to an actual
> arithmetic operator? eval() does not seem to be the answer. TIA!
Maybe you were looking for
print eval(num1 + op + num2) # it's a little ugly string concatenation.
Hm? (untested, but it works in my head.)
Cheers,
Xav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090828/d29013b2/attachment-0001.html>
More information about the Python-list
mailing list