Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Using class expressions for declarative programming in python
- import traceback
- import inspect
- classes = {}
- def route(path, func, *methods):
- clsname = inspect.currentframe().f_back.f_code.co_name
- classes.setdefault(clsname, []).extend([path, func, *methods])
- def foo():
- pass
- class Routes:
- # When this run Routes class doesn't exists yet
- route('/foo', foo, 'POST', 'GET')
- print(classes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement