diff --git a/ft4222/ft4222.pyx b/ft4222/ft4222.pyx index fc14dff..00bca8d 100644 --- a/ft4222/ft4222.pyx +++ b/ft4222/ft4222.pyx @@ -181,6 +181,12 @@ cdef class FT4222: FT4222_UnInitialize(self._handle) FT_Close(self._handle) + def __enter__(self): + return self + + def __exit__(self, type, value, traceback): + self.close() + def close(self): """Closes the device.""" status = FT4222_UnInitialize(self._handle)