]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Explain comments at the start of chapter 3. This is needed since they
authorFred Drake <fdrake@acm.org>
Thu, 29 Apr 1999 13:20:25 +0000 (13:20 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 29 Apr 1999 13:20:25 +0000 (13:20 +0000)
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>.

Doc/tut/tut.tex

index f118e709bdc56b253ac8d67e21e125505eb96b6c..68929de966fe4b673d73918f28ce60830a77b7dd 100644 (file)
@@ -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