Hacker News new | ask | show | jobs
by rnnr 2720 days ago
it's subjective of course, but I find context manager decorators very pythonic, I still remember the 'whoa! that's beautiful' moment when I 1st learned about them.

But most importantly, generators as enclosures are used everywhere today with the whole async-await paradigm.

1 comments

I absolutely agree – it's the specific usage in the class that I don't like. Having a factory instead of using the constructor, with that IMHO not that obvious interaction with the context manage. A factory that is actually a context manager just seems non-trivial, and given that there is more straightforward solution available, I would avoid it.