Skip to content

Commit 418c14f

Browse files
committed
Technical feedback
1 parent b3883eb commit 418c14f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

source/data-formats/bson.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,20 @@ Write BSON to a File
8383

8484
To write BSON data to a file, open a file stream in write-binary mode on the output file.
8585
Then, write each document to the output file. Ensure that documents are encoded in BSON
86-
format by using the ``BSON.encode()`` method.
86+
format by using the ``bson.encode()`` method.
8787

8888
The following example writes the sample BSON document to ``file.bson``:
8989

9090
.. code-block:: python
9191

92-
import bson
93-
9492
with open("file.bson", "w") as file:
95-
file.write(BSON.encode(document))
93+
file.write(bson.encode(document))
9694

9795
Read BSON from a File
9896
---------------------
9997

10098
To read BSON documents from a file, open a file stream in read-binary mode on the input
101-
file. Then, decode the documents from BSON format as you read them by using the ``BSON.decode()``
99+
file. Then, decode the documents from BSON format as you read them by using the ``bson.decode()``
102100
method.
103101

104102
The following example reads the sample BSON document from ``file.bson``:
@@ -111,7 +109,7 @@ The following example reads the sample BSON document from ``file.bson``:
111109

112110
with open("file.bson", "rb") as file:
113111
data = file.read()
114-
document = BSON(data).decode()
112+
document = bson.decode(data)
115113
print(document)
116114

117115
.. output::

0 commit comments

Comments
 (0)