@@ -271,14 +271,10 @@ equality. In pseudocode, the object type looks something like:
271
271
272
272
The default implementation defines equality in terms of identity. Note that
273
273
`Object ` does not define comparison methods like less-than or
274
- greater-than. Instances of `object ` can *not * be stored in a
274
+ greater-than. While Python objects are comparable by default in Python 2, the
275
+ feature was removed in Python 3. Instances of `object ` can *not * be stored in a
275
276
:class: `SortedList `.
276
277
277
- >>> sl = SortedList([object (), object (), object ()])
278
- Traceback (most recent call last):
279
- ...
280
- TypeError: '<' not supported between instances of 'object' and 'object'
281
-
282
278
We can extend this example by creating our own `Record ` data type with `name `
283
279
and `rank ` attributes.
284
280
@@ -298,13 +294,9 @@ define comparison operators and so can *not* be stored in a
298
294
>>> alice1 = Record(' alice' , 1 )
299
295
>>> bob2 = Record(' bob' , 2 )
300
296
>>> carol3 = Record(' carol' , 3 )
301
- >>> sl = SortedList([alice1, bob2, carol3])
302
- Traceback (most recent call last):
303
- ...
304
- TypeError: '<' not supported between instances of 'Record' and 'Record'
305
297
306
- Since the `rank ` attribute is intended for ordering records, the
307
- key-function presents a tempting but invalid use for ordering records::
298
+ Since the `rank ` attribute is intended for ordering records, the key-function
299
+ presents a tempting but invalid use for ordering records::
308
300
309
301
>>> get_rank = lambda record: record.rank
310
302
>>> sl = SortedList([alice1, bob2, carol3], key=get_rank)
0 commit comments