Created
August 21, 2016 21:46
-
-
Save vinay13/4c26d1725ab9faf8d3a01901e0033335 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#usr/bin/python | |
#Decorators | |
import json | |
def as_json(func): | |
def wrapper(*args,**kwargs): | |
result = func(*args,**kwargs) | |
return json.dumps(result) | |
return wrapper | |
@as_json | |
def func(x,y): | |
return {x:x+y} | |
print func(3,4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment