Skip to content

Instantly share code, notes, and snippets.

@sojohnnysaid
Last active January 19, 2021 22:57
Show Gist options
  • Select an option

  • Save sojohnnysaid/6a70fe00b03c6ff34a0c0db328262341 to your computer and use it in GitHub Desktop.

Select an option

Save sojohnnysaid/6a70fe00b03c6ff34a0c0db328262341 to your computer and use it in GitHub Desktop.
getting started with python decorators
def plusNineThousandDecorator(function):
def wrapper(number):
return function(number) + 9000
return wrapper
@plusNineThousandDecorator
def returnPositiveNumber(number):
if number > 0:
return number
else:
return 1
print(returnPositiveNumber(42))
# results
# 9042
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment