Last active
April 30, 2020 23:25
-
-
Save johnsonthomassonttf/e881f3e6c1ba875bd40a98276f969838 to your computer and use it in GitHub Desktop.
Getting feedback on one way of calling hooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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