Skip to content
Browse files

Change tabs to 4 spaces

  • Loading branch information...
1 parent e66bc10 commit 1a6dfac4e15f59c324cb5f1e463202549921cb72 @apauley committed Sep 2, 2010
Showing with 22 additions and 22 deletions.
  1. +22 −22 Chapter1/Python/helpers.py
View
44 Chapter1/Python/helpers.py
@@ -6,33 +6,33 @@
example_f = "(3*x) + math.sin(x) - math.exp(x)"
def swap_points(x):
- s = []
- s = x
- s.sort()
- f = s[1]
- sn = s[2]
- t = s[0]
- s[0] = f
- s[1] = sn
- s[2] = t
- return s
+ s = []
+ s = x
+ s.sort()
+ f = s[1]
+ sn = s[2]
+ t = s[0]
+ s[0] = f
+ s[1] = sn
+ s[2] = t
+ return s
def sub_dict(somedict, somekeys, default=math):
- return dict([ (k, somedict.get(k, default)) for k in somekeys ])
+ 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)
+ 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
- print "Using %s to solve %s" % (t,f)
- print "-" * 50
- print "\n"
+ print "\n"
+ print "-" * 50
+ print "Using %s to solve %s" % (t,f)
+ print "-" * 50
+ print "\n"
def print_end():
- print "-" * 50
+ print "-" * 50

0 comments on commit 1a6dfac

Please sign in to comment.
Something went wrong with that request. Please try again.