Advertisement
here2share

# decorator_demo.py

Oct 19th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # decorator_demo.py
  2.  
  3. # example of decorator
  4. def sampleDecorator(func):
  5.     def addingFunction():
  6.         # some new statments or flow control
  7.         print("This is the added decorator text to the actual function.")
  8.         # calling the function
  9.         func()
  10.  
  11.     return addingFunction
  12.  
  13. @sampleDecorator
  14. def actualFunction():
  15.     print("This is the actual function.")
  16.  
  17.  
  18. actualFunction()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement