summaryrefslogtreecommitdiffstats
path: root/Demo/classes
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-07-04 17:38:32 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-07-04 17:38:32 (GMT)
commit06360405dc33e0a33b1a5ec4042df19cb20d8bbc (patch)
tree3883cfc2b4bb90ecdf459f4458690f4ea8d200f5 /Demo/classes
parent2e733c9625abf1912845d37e1eceeb3cc2873afa (diff)
downloadcpython-06360405dc33e0a33b1a5ec4042df19cb20d8bbc.zip
cpython-06360405dc33e0a33b1a5ec4042df19cb20d8bbc.tar.gz
cpython-06360405dc33e0a33b1a5ec4042df19cb20d8bbc.tar.bz2
Fixed doctests
Diffstat (limited to 'Demo/classes')
-rw-r--r--Demo/classes/Rev.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Demo/classes/Rev.py b/Demo/classes/Rev.py
index 7fd78e0..d36ddb9 100644
--- a/Demo/classes/Rev.py
+++ b/Demo/classes/Rev.py
@@ -4,8 +4,7 @@ From: "Steven D. Majewski" <sdm7g@elvis.med.virginia.edu>
It works on mutable or inmutable sequences.
->>> chars = list(Rev('Hello World!'))
->>> print ''.join(chars)
+>>> Rev('Hello World!')
!dlroW olleH
The .forw is so you can use anonymous sequences in __init__, and still
@@ -16,16 +15,16 @@ good reason to use anonymous values in creating the sequence to avoid
confusion. Maybe it should be change to copy input sequence to break
the connection completely ? )
->>> nnn = range(3)
+>>> nnn = list(range(3))
>>> rnn = Rev(nnn)
->>> for n in rnn: print n
+>>> for n in rnn: n
...
2
1
0
>>> for n in range(4, 6): nnn.append(n) # update nnn
...
->>> for n in rnn: print n # prints reversed updated values
+>>> for n in rnn: n # prints reversed updated values
...
5
4
@@ -35,7 +34,7 @@ the connection completely ? )
>>> nnn = nnn[1:-1]
>>> nnn
[1, 2, 4]
->>> for n in rnn: print n # prints reversed values of old nnn
+>>> for n in rnn: n # prints reversed values of old nnn
...
5
4
@@ -45,16 +44,15 @@ the connection completely ? )
#
>>> WH = Rev('Hello World!')
->>> print WH.forw, WH.back
+>>> print(WH.forw, WH.back)
Hello World! !dlroW olleH
->>> nnn = Rev(range(1, 10))
->>> print nnn.forw
+>>> nnn = Rev(list(range(1, 10)))
+>>> print(nnn.forw)
[1, 2, 3, 4, 5, 6, 7, 8, 9]
->>> print nnn.back
+>>> print(nnn.back)
[9, 8, 7, 6, 5, 4, 3, 2, 1]
->>> rrr = Rev(nnn)
->>> rrr
+>>> Rev(nnn)
<1, 2, 3, 4, 5, 6, 7, 8, 9>
'''