3 ms·
Wouldn't it be more natural to do this sort of thing with decorators?
by nurbl 6y ago
Wouldn't it be more natural to do this sort of thing with decorators?
- Groxx 6y agoFor trivial examples, sure. And there are a lot of those in practice, so it definitely applies sometimes. But decorators aren't really usable when you have any intermediate steps that need to be done, like def do_thing(): with a_lock check_f_cache_while_locked() # like this with open('foo', 'r') as f populate_cache(f)