We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2c5f8b0 commit f74e5ccCopy full SHA for f74e5cc
README.md
@@ -766,21 +766,21 @@ class Counter:
766
767
### Withable
768
```python
769
-class FileReader():
+class MyOpen():
770
def __init__(self, filename):
771
self.filename = filename
772
def __enter__(self):
773
self.file = open(self.filename)
774
- return self.file.read()
+ return self.file
775
def __exit__(self, *args):
776
self.file.close()
777
```
778
779
780
>>> with open('test.txt', 'w') as file:
781
... file.write('Hello World!')
782
->>> with FileReader('test.txt') as text:
783
-... print(text)
+>>> with MyOpen('test.txt') as file:
+... print(file.read())
784
Hello World!
785
786
0 commit comments