Issue 3503: Calls to print() function in Python 3.0 tutorial (original) (raw)

Issue3503

Created on 2008-08-05 01:51 by jsizelove, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
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 http://docs.python.org/dev/3.0/tutorial/modules.html). 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 tutorial.
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.
History
Date User Action Args
2022-04-11 14:56:37 admin set github: 47753
2008-08-05 09:05:20 georg.brandl set status: open -> closedresolution: fixedmessages: +
2008-08-05 01:51:03 jsizelove create