Skip to content

Commit 38b58a9

Browse files
authored
fix(description): open builtin description
Remove empty section tag and add descriptions
1 parent cfda284 commit 38b58a9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: docs/builtin/open.md

+15-5
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,19 @@ Python open() built-in function
1919
## Examples
2020

2121
```python
22-
f = open("some_file.txt", "r")
23-
```
22+
>>> spam = open('spam.txt', mode='x')
23+
>>> spam.write('My first line\n\n')
24+
>>> spam.close()
25+
# Opens a brand new file (in 'x' mode will throw if already exists)
26+
27+
>>> with open('spam.txt', mode='a') as spam:
28+
... spam.write('My second line')
29+
# Appends to file and automatically closes afterward
2430

25-
<!-- remove this tag to start editing this page -->
26-
<empty-section />
27-
<!-- remove this tag to start editing this page -->
31+
>>> with open('spam.txt') as spam:
32+
... content = spam.read()
33+
... print(content)
34+
# My first line
35+
#
36+
# My second line
37+
```

0 commit comments

Comments
 (0)