Tutorial update for 3.0 by Paul Dubois.
I had to fix a few markup issues in controlflow.rst and modules.rst.
There's a unicode issue on line 448 in introduction.rst that someone else needs to fix.
diff --git a/Doc/tutorial/classes.rst b/Doc/tutorial/classes.rst
index b733e1e..09cc0e1 100644
--- a/Doc/tutorial/classes.rst
+++ b/Doc/tutorial/classes.rst
@@ -14,7 +14,8 @@
class or classes, and a method can call the method of a base class with the same
name. Objects can contain an arbitrary amount of private data.
-In C++ terminology, all class members (including the data members) are *public*,
+In C++ terminology, normally class members (including the data members) are
+*public* (except see below :ref:`tut-private`),
and all member functions are *virtual*. There are no special constructors or
destructors. As in Modula-3, there are no shorthands for referencing the
object's members from its methods: the method function is declared with an
@@ -273,7 +274,7 @@
x.counter = 1
while x.counter < 10:
x.counter = x.counter * 2
- print x.counter
+ print(x.counter)
del x.counter
The other kind of instance attribute reference is a *method*. A method is a
@@ -308,7 +309,7 @@
xf = x.f
while True:
- print xf()
+ print(xf())
will continue to print ``hello world`` until the end of time.
@@ -621,11 +622,11 @@
try:
raise c()
except D:
- print "D"
+ print("D")
except C:
- print "C"
+ print("C")
except B:
- print "B"
+ print("B")
Note that if the except clauses were reversed (with ``except B`` first), it
would have printed B, B, B --- the first matching except clause is triggered.
@@ -644,15 +645,15 @@
using a :keyword:`for` statement::
for element in [1, 2, 3]:
- print element
+ print(element)
for element in (1, 2, 3):
- print element
+ print(element)
for key in {'one':1, 'two':2}:
- print key
+ print(key)
for char in "123":
- print char
+ print(char)
for line in open("myfile.txt"):
- print line
+ print(line)
This style of access is clear, concise, and convenient. The use of iterators
pervades and unifies Python. Behind the scenes, the :keyword:`for` statement
@@ -699,7 +700,7 @@
return self.data[self.index]
>>> for char in Reverse('spam'):
- ... print char
+ ... print(char)
...
m
a
@@ -724,7 +725,7 @@
yield data[index]
>>> for char in reverse('golf'):
- ... print char
+ ... print(char)
...
f
l