Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove over-complex evaluate function. No longer needed

  • Loading branch information...
commit d50dc3fed2ae0424f3055024de5134eed5fd8367 1 parent 9b222cd
@apauley authored
Showing with 0 additions and 10 deletions.
  1. +0 −10 Chapter1/Python/
10 Chapter1/Python/
@@ -23,16 +23,6 @@ def swap_points(x):
s[2] = t
return s
-def sub_dict(somedict, somekeys, default=math):
- return dict([ (k, somedict.get(k, default)) for k in somekeys ])
-def evaluate(func, x):
- safe_list = ['math','acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh', 'de grees', 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log', 'log10', 'modf', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh'] #use the list to filter the local namespace
- safe_dict = sub_dict(locals(),safe_list)
- safe_dict['abs'] = abs
- safe_dict['x']=x
- return eval(compile(func,"",'eval'),{"__builtins__":{}},safe_dict)
def print_header(t, f):
print "\n"
print "-" * 50
Please sign in to comment.
Something went wrong with that request. Please try again.