X-Git-Url: http://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=musicpd.py;fp=musicpd.py;h=5824056aac4c364c71943e08a06cc2d5c84334ad;hp=d96e76a54387fcfb7d6ac8db9be83540252edf83;hb=08f23715d963ccdb712133fdceb9e35f62b76561;hpb=9148a096c9939a89ecca79578e5fc2590f2dfd6f diff --git a/musicpd.py b/musicpd.py index d96e76a..5824056 100644 --- a/musicpd.py +++ b/musicpd.py @@ -726,6 +726,13 @@ class MPDClient: self._sock.close() self._reset() + def __enter__(self): + self.connect() + return self + + def __exit__(self, exception_type, exception_value, exception_traceback): + self.disconnect() + def fileno(self): """Return the socket’s file descriptor (a small integer). This is useful with :py:obj:`select.select`.