News for hackers. Stuff that matters.
Re:Python Best Practice Patterns by masklinn on Friday February 28, 2014 @12:04PM (#7319969)
You don't even have to create a full object if there's no need to:

    @contextlib.contextmanager
    def manager(*args):
        object = initialize(args)
        try:
            yield object
        finally:
            # cleanup
            object.close()

There are no comments on this comment yet.