r/Python • • Jun 18 '13

Creating python command-line applications

http://pauloortins.com/creating-python-command-line-applications/
0 Upvotes

20 comments sorted by

View all comments

8

u/utdemir Jun 18 '13

Also,

import operator

functions = {
	'add': operator.add
	'subtract': operator.sub
	'multiply': operator.mul
	'divide': operator.truediv
}

instead of

functions = {
'add': lambda num1, num2: num1 + num2,
'subtract': lambda num1, num2: num1 - num2,
'multiply': lambda num1, num2: num1 * num2,
'divide': lambda num1, num2: num1 / num2
}