Skip to content

Instantly share code, notes, and snippets.

@jaklinger
Created May 5, 2020 15:42
Show Gist options
  • Save jaklinger/d2961e8cb21a95e5d5d3db5558d586fc to your computer and use it in GitHub Desktop.
Save jaklinger/d2961e8cb21a95e5d5d3db5558d586fc to your computer and use it in GitHub Desktop.
after decorator example
def do_the_other_thing(run, output):
def wrap(self):
run(self)
output(self)
return wrap
class A:
name='a'
def run(self):
pass
def hello(self):
print('hello')
def output(self):
self.hello()
def __init_subclass__(cls):
super().__init_subclass__()
cls.run = do_the_other_thing(cls.run, cls.output)
# do some other work
class B(A):
name='b'
def run(self):
print("running!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment