Skip to content

Latest commit

 

History

History
18 lines (17 loc) · 1.01 KB

File metadata and controls

18 lines (17 loc) · 1.01 KB

Python Decorator Examples

  • Pretty common use of decorators for wrapping functions.
  • Pretty common use of decorators for registering a function to some event or whatnot.
  • Make a decorator function that itself can take parameters.
  • Demonstrates how python decorators run and overwrite a function. Not super useful aside from understanding decorators.
  • Basic wrapper with a lambda instead of closure.
  • Wrap a function that takes arguments.
  • How to deal with decorating your class method (with "self" parameter) when the decorator doesn't want to cooperate with the "self" parameter.
  • How a closure works on its own.