summaryrefslogtreecommitdiffstats
path: root/Demo
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-10-25 20:25:43 (GMT)
committerGeorg Brandl <georg@python.org>2009-10-25 20:25:43 (GMT)
commitf1ca811abb26b9ade70cb80ddc2dc8ed89b330b3 (patch)
tree10c01ef886fd2b57303289124408360ebda12912 /Demo
parent8c3fb3944050687769f474ad6cc176f35c90bc81 (diff)
downloadcpython-f1ca811abb26b9ade70cb80ddc2dc8ed89b330b3.zip
cpython-f1ca811abb26b9ade70cb80ddc2dc8ed89b330b3.tar.gz
cpython-f1ca811abb26b9ade70cb80ddc2dc8ed89b330b3.tar.bz2
Fix a demo.
Diffstat (limited to 'Demo')
-rwxr-xr-xDemo/comparisons/sortingtest.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/Demo/comparisons/sortingtest.py b/Demo/comparisons/sortingtest.py
index cabf626..08a73e3 100755
--- a/Demo/comparisons/sortingtest.py
+++ b/Demo/comparisons/sortingtest.py
@@ -24,7 +24,6 @@
# - Handles blank input lines correctly
import re
-import string
import sys
def main():
@@ -32,18 +31,13 @@ def main():
def makekey(item, prog=prog):
match = prog.match(item)
if match:
- var, num = match.group(1, 2)
- return string.atoi(num), var
+ var, num = match.groups()
+ return int(num), var
else:
# Bad input -- pretend it's a var with value 0
return 0, item
- while 1:
- line = sys.stdin.readline()
- if not line:
- break
- items = line.split()
- items = map(makekey, items)
- items.sort()
+ for line in sys.stdin:
+ items = sorted(makekey(item) for item in line.split())
for num, var in items:
print "%s=%s" % (var, num),
print