Skip to content

Commit 0b79b12

Browse files
committed
Update readme to use a context manager
1 parent f8eebcd commit 0b79b12

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,8 @@ Initialize the GPIB adapter
5757
```python
5858
from async_gpib.async_gpib import AsyncGpib
5959
# Create a controller and talk to device address 22
60-
gpib_device = AsyncGpib(name=0, pad=22)
61-
62-
# Connect to the controller. This must be done inside the loop
63-
await gpib_device.connect()
64-
65-
# Add your code here
66-
67-
# Disconnect after we are done
68-
await gpib_device.disconnect()
60+
async with AsyncGpib(name=0, pad=22) as gpib_device:
61+
...
6962
```
7063
See [examples/](examples/) for more working examples.
7164

@@ -87,4 +80,3 @@ I use the [Numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) styl
8780

8881

8982
This project is licensed under the GPL v3 license - see the [LICENSE](LICENSE) file for details
90-

0 commit comments

Comments
 (0)