Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
753a68e2
Commit
753a68e2
authored
Jan 18, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bite the bullet: use rich comparisons here, too.
parent
9710bd5d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
Lib/UserList.py
Lib/UserList.py
+10
-4
No files found.
Lib/UserList.py
View file @
753a68e2
...
...
@@ -12,11 +12,17 @@ class UserList:
else
:
self
.
data
=
list
(
initlist
)
def
__repr__
(
self
):
return
repr
(
self
.
data
)
def
__lt__
(
self
,
other
):
return
self
.
data
<
self
.
__cast
(
other
)
def
__le__
(
self
,
other
):
return
self
.
data
<=
self
.
__cast
(
other
)
def
__eq__
(
self
,
other
):
return
self
.
data
==
self
.
__cast
(
other
)
def
__ne__
(
self
,
other
):
return
self
.
data
!=
self
.
__cast
(
other
)
def
__gt__
(
self
,
other
):
return
self
.
data
>
self
.
__cast
(
other
)
def
__ge__
(
self
,
other
):
return
self
.
data
>=
self
.
__cast
(
other
)
def
__cast
(
self
,
other
):
if
isinstance
(
other
,
UserList
):
return
other
.
data
else
:
return
other
def
__cmp__
(
self
,
other
):
if
isinstance
(
other
,
UserList
):
return
cmp
(
self
.
data
,
other
.
data
)
else
:
return
cmp
(
self
.
data
,
other
)
raise
RuntimeError
,
"UserList.__cmp__() is obsolete"
def
__contains__
(
self
,
item
):
return
item
in
self
.
data
def
__len__
(
self
):
return
len
(
self
.
data
)
def
__getitem__
(
self
,
i
):
return
self
.
data
[
i
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment