Hacker News new | ask | show | jobs
by softbuilder 5385 days ago
Fellow hell-bound soul here. I didn't go nearly as far as you did. I decided it would be fun to have guards in Python and decorators were just the tool. I sketched this out as part of a talk at Open Source Bridge a few years back:

https://github.com/built/Jane-Kelly/blob/master/guard.py

It'll let you redefine functions with different guard parameters. (@when("x=5"), @when("x>20"), etc.) Like you, I would also shudder to see this in production. But it was fun and shows off some of what's possible.