mod_util.py

changeset 107
14e1d18d2a2a
parent 106
31583e5b2f49
child 111
44d9aea72947
equal deleted inserted replaced
106:31583e5b2f49 107:14e1d18d2a2a
131 def cmd_calc (bot, replyto, args, **rest): 131 def cmd_calc (bot, replyto, args, **rest):
132 expr = args['expression'] 132 expr = args['expression']
133 133
134 try: 134 try:
135 # Substitute some mathematical constants 135 # Substitute some mathematical constants
136 expr = mathsubstitute (expr, 'pi' , 3.141592653589793) 136 expr = mathsubstitute (expr, 'pi' , 3.14159265358979323846264338327950288419716939937510)
137 expr = mathsubstitute (expr, 'e' , 2.718281828459045) 137 expr = mathsubstitute (expr, 'e' , 2.71828182845904523536028747135266249775724709369995)
138 expr = mathsubstitute (expr, 'phi', 1.618033988749895) # golden ratio 138 expr = mathsubstitute (expr, 'phi', 1.6180339887498948482) # golden ratio
139 139
140 result = subprocess.check_output (['calc', expr], stderr=subprocess.STDOUT) \ 140 result = subprocess.check_output (['calc', expr], stderr=subprocess.STDOUT) \
141 .replace ('\t', '') \ 141 .replace ('\t', '') \
142 .replace ('\n', '') 142 .replace ('\n', '')
143 143

mercurial