On 27/11/23 5:03 pm, Grant Edwards wrote:
I should probably have written "how to fool that <something> into
working when he's not using a 'with' statement"
It should be possible to run the context protocol yourself.
Something like (warning, untested):
class MyDeviceWrapper:
def __init__(self):
self.cm = device_open()
self.device = self.cm.__enter__()
# Other methods here for doing things with
# self.device
def close(self):
self.cm.__exit__(None, None, None)
--
Greg
--
https://mail.python.org/mailman/listinfo/python-list