Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.