diff options
author | Raymond Hettinger <python@rcn.com> | 2004-08-16 01:35:28 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2004-08-16 01:35:28 (GMT) |
commit | 3258e72c82fa66b633f06434375ddaa9c96c5700 (patch) | |
tree | df1d33f914ca80898beaa8da16d2844ea632dd0e /Lib/test/test_genexps.py | |
parent | 8df4e6b0207e7a09d30e9216f9a0f0a8e7c7dd75 (diff) | |
download | cpython-3258e72c82fa66b633f06434375ddaa9c96c5700.zip cpython-3258e72c82fa66b633f06434375ddaa9c96c5700.tar.gz cpython-3258e72c82fa66b633f06434375ddaa9c96c5700.tar.bz2 |
* Uncomment the SyntaxError doctest after Tim demonstrated how.
* Remove unnecessary sys.PS2 prompt lines.
Diffstat (limited to 'Lib/test/test_genexps.py')
-rw-r--r-- | Lib/test/test_genexps.py | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py index dc26ed6..e43f593 100644 --- a/Lib/test/test_genexps.py +++ b/Lib/test/test_genexps.py @@ -60,28 +60,26 @@ Test running gen when defining function is out of scope >>> def f(n): ... return (i*i for i in xrange(n)) - ... >>> list(f(10)) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] >>> def f(n): ... return ((i,j) for i in xrange(3) for j in xrange(n)) - ... >>> list(f(4)) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)] >>> def f(n): ... return ((i,j) for i in xrange(3) for j in xrange(4) if j in xrange(n)) - ... >>> list(f(4)) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)] >>> list(f(2)) [(0, 0), (0, 1), (1, 0), (1, 1), (2, 0), (2, 1)] -#Verify that parenthesis are required in a statement -#>>> def f(n): -#... return i*i for i in xrange(n) -#... -#SyntaxError: invalid syntax +Verify that parenthesis are required in a statement +>>> def f(n): +... return i*i for i in xrange(n) +Traceback (most recent call last): + ... +SyntaxError: invalid syntax Verify early binding for the outermost for-expression @@ -137,12 +135,10 @@ Generators always return to the most recent caller: ... r = yrange(5) ... print "creator", r.next() ... return r - ... >>> def caller(): ... r = creator() ... for i in r: ... print "caller", i - ... >>> caller() creator 0 caller 1 @@ -155,7 +151,6 @@ Generators can call other generators: >>> def zrange(n): ... for i in yrange(n): ... yield i - ... >>> list(zrange(5)) [0, 1, 2, 3, 4] |