diff --git a/tests/test-highlight.t b/tests/test-highlight.t --- a/tests/test-highlight.t +++ b/tests/test-highlight.t @@ -49,7 +49,7 @@ > except (ValueError, IndexError): > n = 10 > p = primes() - > print "The first %d primes: %s" % (n, list(islice(p, n))) + > print("The first %d primes: %s" % (n, list(islice(p, n)))) > EOF $ echo >> primes.py # to test html markup with an empty line just before EOF $ hg ci -Ama @@ -74,7 +74,7 @@ - test: 1af356141006 primes.py + test: f4fca47b67e6 primes.py @@ -112,7 +112,7 @@

- view primes.py @ 0:1af356141006 + view primes.py @ 0:f4fca47b67e6 tip

@@ -182,7 +182,7 @@ except (ValueError, IndexError): n = 10 p = primes() - print "The first %d primes: %s" % (n, list(islice(p, n))) + print("The first %d primes: %s" % (n, list(islice(p, n))))
@@ -251,7 +251,7 @@

- annotate primes.py @ 0:1af356141006 + annotate primes.py @ 0:f4fca47b67e6 tip

@@ -299,19 +299,19 @@ - + 0
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
1 """Fun with generators. Corresponding Haskell implementation: @@ -321,14 +321,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
2 @@ -338,14 +338,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
3 primes = 2 : sieve [3, 5..] @@ -355,14 +355,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
4 where sieve (p:ns) = p : sieve [n | n <- ns, mod n p /= 0] @@ -372,14 +372,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
5 """ @@ -389,14 +389,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
6 @@ -406,14 +406,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
7 from itertools import dropwhile, ifilter, islice, count, chain @@ -423,14 +423,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
8 @@ -440,14 +440,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
9 def primes(): @@ -457,14 +457,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
10 """Generate all primes.""" @@ -474,14 +474,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
11 def sieve(ns): @@ -491,14 +491,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
12 p = ns.next() @@ -508,14 +508,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
13 # It is important to yield *here* in order to stop the @@ -525,14 +525,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
14 # infinite recursion. @@ -542,14 +542,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
15 yield p @@ -559,14 +559,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
16 ns = ifilter(lambda n: n % p != 0, ns) @@ -576,14 +576,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
17 for n in sieve(ns): @@ -593,14 +593,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
18 yield n @@ -610,14 +610,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
19 @@ -627,14 +627,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
20 odds = ifilter(lambda i: i % 2 == 1, count()) @@ -644,14 +644,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
21 return chain([2], sieve(dropwhile(lambda n: n < 3, odds))) @@ -661,14 +661,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
22 @@ -678,14 +678,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
23 if __name__ == "__main__": @@ -695,14 +695,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
24 import sys @@ -712,14 +712,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
25 try: @@ -729,14 +729,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
26 n = int(sys.argv[1]) @@ -746,14 +746,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
27 except (ValueError, IndexError): @@ -763,14 +763,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
28 n = 10 @@ -780,14 +780,14 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
29 p = primes() @@ -797,31 +797,31 @@
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
- 30 print "The first %d primes: %s" % (n, list(islice(p, n))) + 30 print("The first %d primes: %s" % (n, list(islice(p, n))))
- - 1af356141006 + + f4fca47b67e6 a
test
parents:
- diff - changeset + diff + changeset
31