summaryrefslogtreecommitdiffstats
path: root/Doc/tut
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-04-29 13:20:25 (GMT)
committerFred Drake <fdrake@acm.org>1999-04-29 13:20:25 (GMT)
commitbdadf0f7f313cf449e56ca64a0d2784f1167cb90 (patch)
tree3a7ae4a35b8c435ee3505c1b637541ce66b0d558 /Doc/tut
parent0e1de8bd6b48e09d50139f57eedb9857a1e2bf97 (diff)
downloadcpython-bdadf0f7f313cf449e56ca64a0d2784f1167cb90.zip
cpython-bdadf0f7f313cf449e56ca64a0d2784f1167cb90.tar.gz
cpython-bdadf0f7f313cf449e56ca64a0d2784f1167cb90.tar.bz2
Explain comments at the start of chapter 3. This is needed since they
appear in the examples without any further explanation, and the tutorial doesn't have this information explicit anywhere else. Omission reported by Jon Black <jblack@Ridgeway-Sys.com>.
Diffstat (limited to 'Doc/tut')
-rw-r--r--Doc/tut/tut.tex23
1 files changed, 21 insertions, 2 deletions
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index f118e70..68929de 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -285,7 +285,9 @@ executable, like shell scripts, by putting the line
(assuming that the interpreter is on the user's \envvar{PATH}) at the
beginning of the script and giving the file an executable mode. The
-\samp{\#!} must be the first two characters of the file.
+\samp{\#!} must be the first two characters of the file. Note that
+the hash, or pound, character, \character{\#}, is used to start a
+comment in Python.
\subsection{The Interactive Startup File \label{startup}}
@@ -328,7 +330,7 @@ In the following examples, input and output are distinguished by the
presence or absence of prompts (\samp{>>> } and \samp{... }): to repeat
the example, you must type everything after the prompt, when the
prompt appears; lines that do not begin with a prompt are output from
-the interpreter.%
+the interpreter. %
%\footnote{
% I'd prefer to use different fonts to distinguish input
% from output, but the amount of LaTeX hacking that would require
@@ -337,6 +339,23 @@ the interpreter.%
Note that a secondary prompt on a line by itself in an example means
you must type a blank line; this is used to end a multi-line command.
+Many of the examples in this manual, even those entered at the
+interactive prompt, include comments. Comments in Python start with
+the hash character, \character{\#}, and extend to the end of the
+physical line. A comment may appear at the start of a line or
+following whitespace or code, but not within a string literal. A hash
+character within a string literal is just a hash character.
+
+Some examples:
+
+\begin{verbatim}
+# this is the first comment
+SPAM = 1 # and this is the second comment
+ # ... and now a third!
+STRING = "# This is not a comment."
+\end{verbatim}
+
+
\section{Using Python as a Calculator \label{calculator}}
Let's try some simple Python commands. Start the interpreter and wait