You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+5-6Lines changed: 5 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1154,17 +1154,13 @@ class MyOpen():
1154
1154
Hello World!
1155
1155
```
1156
1156
1157
-
#### Context managers:
1157
+
#### List of existing context managers:
1158
1158
```python
1159
1159
withopen('<path>', ...) asfile: ...
1160
1160
with wave.open('<path>', ...) as wave_file: ...
1161
1161
withmemoryview(<bytes/bytearray/array>) as view: ...
1162
-
```
1163
-
1164
-
#### Reusable context managers:
1165
-
```python
1162
+
db = sqlite3.connect('<path>'); with db: db.execute('<insert_query>')
1166
1163
lock = threading.RLock(); with lock: ...
1167
-
con = sqlite3.connect('<path>'); with con: con.execute('<insert_query>')
1168
1164
```
1169
1165
1170
1166
@@ -1232,6 +1228,7 @@ class MySequence:
1232
1228
***It's a richer interface than the basic sequence.**
1233
1229
***Extending it generates iter(), contains(), reversed(), index(), and count().**
1234
1230
***Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, collections.abc.Sequence)'` would return 'False' even if it had all the methods defined.**
1231
+
1235
1232
```python
1236
1233
classMyAbcSequence(collections.abc.Sequence):
1237
1234
def__init__(self, a):
@@ -1258,6 +1255,8 @@ class MyAbcSequence(collections.abc.Sequence):
0 commit comments