Title: Calls to print() function in Python 3.0 tutorial
Type: Stage:
Components: Documentation Versions: Python 3.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, jsizelove
Priority: normal Keywords: patch

Created on 2008-08-05 01:51 by jsizelove, last changed 2008-08-05 09:05 by georg.brandl. This issue is now closed.

File name Uploaded Description Edit
print.diff jsizelove, 2008-08-05 01:51
Messages (2)
msg70727 - (view) Author: Jim Sizelove (jsizelove) Date: 2008-08-05 01:50
I decided to learn more about the coming changes in Python 3.0 by
installing the beta and working through the tutorial.  I found some
discrepancies between the code examples and the output I got.  The
attached patch shows several places where the print() function is called
incorrectly.  These are mostly examples that are missing the parentheses.

The rest of this comment pertains to only one change included in the
patch that I find less than satisfactory.  In introduction.html, there
is an example of printing a fibonacci sequence in one line of output by
using the end keyword.  When actually run in the python interpreter, the
>>> prompt shows at the end of the same line as the fibonacci numbers. 
The patch fixes this by enclosing a "print()" within an else clause.

This "fix" produces the expected output, but I don't think the else
clause has been described yet in the tutorial.  A better fix would be to
wrap the while statement in a function with a print() function call
after the end of the while statement (this is how the fib() function is
defined in  But
functions have not been explained this early in the tutorial.

Perhaps it would be best to drop this example of using the end keyword
to the print function in the introduction and explain it later in the
msg70731 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-05 09:05
Thanks for the patch! Committed in r65545.

For the fibonacci example, I just left out the final print(). For
simplicity's case, it's fine for the example to have the minor flaw of
not printing a final newline -- it is there to show the end keyword,
after all.
Date User Action Args
2008-08-05 09:05:20georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg70731
2008-08-05 01:51:03jsizelovecreate