Skip to content

Instantly share code, notes, and snippets.

@JackInTaiwan
Created November 4, 2018 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackInTaiwan/6f70279c19ed337a58c875f8f2f75cae to your computer and use it in GitHub Desktop.
Save JackInTaiwan/6f70279c19ed337a58c875f8f2f75cae to your computer and use it in GitHub Desktop.
class Dog:
def __init__(self, func):
self.age = 10
self.talent = func
def bark(self):
print("Bark !!!")
@Dog
def dog_can_pee():
print("I can pee very hard......")
if __name__ == "__main__":
dog = dog_can_pee
print(dog.age)
# > 10
dog.bark()
# > Bark !!!
dog.talent()
# > I can pee very hard......
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment