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
6b59f5f3
Commit
6b59f5f3
authored
Oct 16, 2003
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let library modules use the new keyword arguments for list.sort().
parent
42b1ba31
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
18 additions
and
24 deletions
+18
-24
Lib/SimpleHTTPServer.py
Lib/SimpleHTTPServer.py
+1
-1
Lib/UserList.py
Lib/UserList.py
+1
-1
Lib/_strptime.py
Lib/_strptime.py
+9
-11
Lib/difflib.py
Lib/difflib.py
+4
-8
Lib/inspect.py
Lib/inspect.py
+1
-1
Lib/pydoc.py
Lib/pydoc.py
+1
-1
Lib/sre_constants.py
Lib/sre_constants.py
+1
-1
No files found.
Lib/SimpleHTTPServer.py
View file @
6b59f5f3
...
...
@@ -99,7 +99,7 @@ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
except
os
.
error
:
self
.
send_error
(
404
,
"No permission to list directory"
)
return
None
list
.
sort
(
lambda
a
,
b
:
cmp
(
a
.
lower
(),
b
.
lower
()
))
list
.
sort
(
key
=
lambda
a
:
a
.
lower
(
))
f
=
StringIO
()
f
.
write
(
"<title>Directory listing for %s</title>
\
n
"
%
self
.
path
)
f
.
write
(
"<h2>Directory listing for %s</h2>
\
n
"
%
self
.
path
)
...
...
Lib/UserList.py
View file @
6b59f5f3
...
...
@@ -77,7 +77,7 @@ class UserList:
def
count
(
self
,
item
):
return
self
.
data
.
count
(
item
)
def
index
(
self
,
item
,
*
args
):
return
self
.
data
.
index
(
item
,
*
args
)
def
reverse
(
self
):
self
.
data
.
reverse
()
def
sort
(
self
,
*
args
):
self
.
data
.
sort
(
*
arg
s
)
def
sort
(
self
,
*
args
,
**
kwds
):
self
.
data
.
sort
(
*
args
,
**
kwd
s
)
def
extend
(
self
,
other
):
if
isinstance
(
other
,
UserList
):
self
.
data
.
extend
(
other
.
data
)
...
...
Lib/_strptime.py
View file @
6b59f5f3
...
...
@@ -231,10 +231,8 @@ class TimeRE(dict):
break
else
:
return
''
to_sort
=
[(
len
(
item
),
item
)
for
item
in
to_convert
]
to_sort
.
sort
()
to_sort
.
reverse
()
to_convert
=
[
item
for
length
,
item
in
to_sort
]
to_convert
=
to_convert
[:]
to_convert
.
sort
(
key
=
len
,
reverse
=
True
)
regex
=
'|'
.
join
(
to_convert
)
regex
=
'(?P<%s>%s'
%
(
directive
,
regex
)
return
'%s)'
%
regex
...
...
Lib/difflib.py
View file @
6b59f5f3
...
...
@@ -701,15 +701,11 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
s
.
quick_ratio
()
>=
cutoff
and
\
s
.
ratio
()
>=
cutoff
:
result
.
append
((
s
.
ratio
(),
x
))
# Sort by score.
result
.
sort
()
# Retain only the best n.
result
=
result
[
-
n
:]
# Move best-scorer to head of list.
result
.
reverse
()
# Strip scores.
return
[
x
for
score
,
x
in
result
]
# Move the best scorers to head of list
result
.
sort
(
reverse
=
True
)
# Strip scores for the best n matches
return
[
x
for
score
,
x
in
result
[:
n
]]
def
_count_leading
(
line
,
ch
):
"""
...
...
Lib/inspect.py
View file @
6b59f5f3
...
...
@@ -553,7 +553,7 @@ def getsource(object):
def
walktree
(
classes
,
children
,
parent
):
"""Recursive helper function for getclasstree()."""
results
=
[]
classes
.
sort
(
lambda
a
,
b
:
cmp
(
a
.
__name__
,
b
.
__name__
)
)
classes
.
sort
(
key
=
lambda
c
:
c
.
__name__
)
for
c
in
classes
:
results
.
append
((
c
,
c
.
__bases__
))
if
c
in
children
:
...
...
Lib/pydoc.py
View file @
6b59f5f3
...
...
@@ -779,7 +779,7 @@ class HTMLDoc(Doc):
tag
+=
':<br>
\
n
'
# Sort attrs by name.
attrs
.
sort
(
lambda
t1
,
t2
:
cmp
(
t1
[
0
],
t2
[
0
])
)
attrs
.
sort
(
key
=
lambda
t
:
t
[
0
]
)
# Pump out the attrs, segregated by kind.
attrs
=
spill
(
'Methods %s'
%
tag
,
attrs
,
...
...
Lib/sre_constants.py
View file @
6b59f5f3
...
...
@@ -219,7 +219,7 @@ if __name__ == "__main__":
import
string
def
dump
(
f
,
d
,
prefix
):
items
=
d
.
items
()
items
.
sort
(
lambda
a
,
b
:
cmp
(
a
[
1
],
b
[
1
])
)
items
.
sort
(
key
=
lambda
a
:
a
[
1
]
)
for
k
,
v
in
items
:
f
.
write
(
"#define %s_%s %s
\
n
"
%
(
prefix
,
string
.
upper
(
k
),
v
))
f
=
open
(
"sre_constants.h"
,
"w"
)
...
...
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