class Action(object):
def __init__(self, name):
self.name = name
def __call__(self, *args, **kwargs):
print(self.name, *args, **kwargs)
actions = [
Action('Hello'),
Action('Bonjour'),
Action('Goodbye'),
]
for action in actions:
action('world')
Item 30: Callable
Posted by Logan Chien