summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames R. Barlow <jim@purplerock.ca>2019-05-10 14:46:11 -0700
committerJames R. Barlow <jim@purplerock.ca>2019-05-10 14:46:11 -0700
commitb352038bf8544b2de02dce292e588e8a3ca4d61f (patch)
treee15357676d0823854e8ecdae702af022dff2c51e
parenta01031c4f65a967c7da23174efc7fa893d80f06b (diff)
Readme: show with-block in demo
-rw-r--r--README.md8
1 files changed, 4 insertions, 4 deletions
diff --git a/README.md b/README.md
index 8a074cf..cfe1b59 100644
--- a/README.md
+++ b/README.md
@@ -11,10 +11,10 @@ Python + QPDF = "py" + "qpdf" = "pyqpdf", which looks like a dyslexia test. Say
```python
# Elegant, Pythonic API
-pdf = pikepdf.open('input.pdf')
-num_pages = len(pdf.pages)
-del pdf.pages[-1]
-pdf.save('output.pdf')
+with pikepdf.open('input.pdf') as pdf:
+ num_pages = len(pdf.pages)
+ del pdf.pages[-1]
+ pdf.save('output.pdf')
```
**To install:**