Skip to content

Instantly share code, notes, and snippets.

@johnsonthomassonttf
Last active April 30, 2020 23:25
Show Gist options
  • Save johnsonthomassonttf/e881f3e6c1ba875bd40a98276f969838 to your computer and use it in GitHub Desktop.
Save johnsonthomassonttf/e881f3e6c1ba875bd40a98276f969838 to your computer and use it in GitHub Desktop.
Getting feedback on one way of calling hooks
class SomeProcess():
def do_it(self):
self.before_doing_it()
# actually do it
# much stuff to be done
self.after_doing_it()
def before_doing_it(self):
pass # Just a hook
def after_doing_it(self):
pass # Just a hook
def do_this_before():
# do something else first
print "before"
def do_this_after():
# do something else after
print "after"
my_process = SomeProcess()
my_process.before_doing_it = do_this_before
my_process.after_doing_it = do_this_after
my_process.do_it()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment