]> granicus.if.org Git - python/commitdiff
Fix a demo.
authorGeorg Brandl <georg@python.org>
Sun, 25 Oct 2009 20:25:43 +0000 (20:25 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 25 Oct 2009 20:25:43 +0000 (20:25 +0000)
Demo/comparisons/sortingtest.py

index cabf6260d9c3bef0adb7565171f1fd4472859742..08a73e3754d987fe5f5013bd1db8a867797cddbb 100755 (executable)
@@ -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