| 1 |
import eggsample |
| 2 |
|
| 3 |
|
| 4 |
@eggsample.hookimpl |
| 5 |
def eggsample_add_ingredients(ingredients): |
| 6 |
"""Here the caller expects us to return a list.""" |
| 7 |
if "egg" in ingredients: |
| 8 |
spam = ["lovely spam", "wonderous spam"] |
| 9 |
else: |
| 10 |
spam = ["splendiferous spam", "magnificent spam"] |
| 11 |
return spam |
| 12 |
|
| 13 |
|
| 14 |
@eggsample.hookimpl |
| 15 |
def eggsample_prep_condiments(condiments): |
| 16 |
"""Here the caller passes a mutable object, so we mess with it directly.""" |
| 17 |
try: |
| 18 |
del condiments["steak sauce"] |
| 19 |
except KeyError: |
| 20 |
pass |
| 21 |
condiments["spam sauce"] = 42 |
| 22 |
return "Now this is what I call a condiments tray!" |