Skip to content

Commit bfbe701

Browse files
wbolsterbehackett
authored andcommitted
Don't overwrite built-in id() function in example
1 parent 930e22c commit bfbe701

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

bson/binary.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,25 @@ class UUIDLegacy(Binary):
137137
138138
>>> import uuid
139139
>>> from bson.binary import Binary, UUIDLegacy
140-
>>> id = uuid.uuid4()
141-
>>> db.test.insert({'uuid': Binary(id.bytes, 3)})
140+
>>> my_uuid = uuid.uuid4()
141+
>>> db.test.insert({'uuid': Binary(my_uuid.bytes, 3)})
142142
ObjectId('...')
143-
>>> db.test.find({'uuid': id}).count()
143+
>>> db.test.find({'uuid': my_uuid}).count()
144144
0
145-
>>> db.test.find({'uuid': UUIDLegacy(id)}).count()
145+
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)}).count()
146146
1
147-
>>> db.test.find({'uuid': UUIDLegacy(id)})[0]['uuid']
147+
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)})[0]['uuid']
148148
UUID('...')
149149
>>>
150150
>>> # Convert from subtype 3 to subtype 4
151-
>>> doc = db.test.find_one({'uuid': UUIDLegacy(id)})
151+
>>> doc = db.test.find_one({'uuid': UUIDLegacy(my_uuid)})
152152
>>> db.test.save(doc)
153153
ObjectId('...')
154-
>>> db.test.find({'uuid': UUIDLegacy(id)}).count()
154+
>>> db.test.find({'uuid': UUIDLegacy(my_uuid)}).count()
155155
0
156-
>>> db.test.find({'uuid': {'$in': [UUIDLegacy(id), id]}}).count()
156+
>>> db.test.find({'uuid': {'$in': [UUIDLegacy(my_uuid), my_uuid]}}).count()
157157
1
158-
>>> db.test.find_one({'uuid': id})['uuid']
158+
>>> db.test.find_one({'uuid': my_uuid})['uuid']
159159
UUID('...')
160160
161161
Raises TypeError if `obj` is not an instance of :class:`~uuid.UUID`.

0 commit comments

Comments
 (0)