Skip to content

Comment on Introduction to Python Decoratorsparent

Comments

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.