Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python str to operator

import operator
ops = { "+": operator.add, "-": operator.sub } # etc.

print(ops["+"](1,1)) # prints 2
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #str #operator
ADD COMMENT
Topic
Name
1+1 =