Python Forum

Full Version: i want to make my own context manager
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i want to make my own context manager. maybe more than one. i'm reading docs for module contextmanager but it seems to not be very thorough. the first one i want to make is to be file-object-like object. that is, it should be usable like a file object, including as a context manager (so its creator can be used in a with statement in place of open(). this is one reason i haven been reading up on file-object methods (to see what all i need to implement.