| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,10 +39,11 @@ def get_product_information(self, product): | |||
| 39 | 39 | if product_info: | |
| 40 | 40 | print('PRODUCT INFORMATION:') | |
| 41 | 41 | print('Name: {0}, Price: {1:.2f}, Quantity: {2:}'.format( | |
| 42 | - product.title(), product_info.get('price', 0), | ||
| 43 | - product_info.get('quantity', 0))) | ||
| 42 | + product.title(), product_info.get('price', 0), | ||
| 43 | + product_info.get('quantity', 0))) | ||
| 44 | 44 | else: | |
| 45 | - print('That product "{0}" does not exist in the records'.format(product)) | ||
| 45 | + print('That product "{0}" does not exist in the records'.format( | ||
| 46 | + product)) | ||
| 46 | 47 | ||
| 47 | 48 | ||
| 48 | 49 | def main(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ def __init__(self): | |||
| 39 | 39 | h1.successor(h2) | |
| 40 | 40 | h2.successor(h3) | |
| 41 | 41 | ||
| 42 | - self.handlers = (h1,h2,h3) | ||
| 42 | + self.handlers = (h1, h2, h3) | ||
| 43 | 43 | ||
| 44 | 44 | def delegate(self, requests): | |
| 45 | 45 | for request in requests: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | # http://stackoverflow.com/questions/3118929/implementing-the-decorator-pattern-in-python | |
| 2 | 2 | ||
| 3 | + | ||
| 3 | 4 | class foo_decorator(object): | |
| 4 | 5 | def __init__(self, decoratee): | |
| 5 | 6 | self._decoratee = decoratee | |
@@ -11,13 +12,15 @@ def f1(self): | |||
| 11 | 12 | def __getattr__(self, name): | |
| 12 | 13 | return getattr(self._decoratee, name) | |
| 13 | 14 | ||
| 15 | + | ||
| 14 | 16 | class undecorated_foo(object): | |
| 15 | 17 | def f1(self): | |
| 16 | 18 | print("original f1") | |
| 17 | 19 | ||
| 18 | 20 | def f2(self): | |
| 19 | 21 | print("original f2") | |
| 20 | 22 | ||
| 23 | + | ||
| 21 | 24 | @foo_decorator | |
| 22 | 25 | class decorated_foo(object): | |
| 23 | 26 | def f1(self): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments