comparison tests/objects.py @ 36:362912842985

start stubbing out wrappers....i am somewhat perplexed
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 07 Jun 2011 19:11:27 -0700
parents 0bea5297c156
children 5268ab85fe1b
comparison
equal deleted inserted replaced
35:850d31be0fb8 36:362912842985
18 class Foo(object): 18 class Foo(object):
19 def __init__(self, a, b): 19 def __init__(self, a, b):
20 self.factor = a*100 + b 20 self.factor = a*100 + b
21 def __call__(self, number): 21 def __call__(self, number):
22 return number * self.factor 22 return number * self.factor
23
24 class Wrapper(object):
25 def __init__(self, app):
26 self.app = app
27 def __call__(self, *args, **kwargs):
28 retval = self.app(*args, **kwargs)
29 values = {1: 'one',
30 2: 'two',
31 3: 'three'} # etc
32 if retval in values:
33 return values[retval]
34 return retval
35
36 def wrap(app):
37 return Wrapper(app)
38
39 def fib(n):
40 """return the nth fibonacci term"""
41