@@ -285,7 +285,9 @@ \subsection{Executable Python Scripts \label{scripts}}
285285
286286(assuming that the interpreter is on the user's \envvar {PATH}) at the
287287beginning of the script and giving the file an executable mode. The
288- \samp {\# !} must be the first two characters of the file.
288+ \samp {\# !} must be the first two characters of the file. Note that
289+ the hash, or pound, character, \character {\# }, is used to start a
290+ comment in Python.
289291
290292\subsection {The Interactive Startup File \label {startup } }
291293
@@ -328,7 +330,7 @@ \chapter{An Informal Introduction to Python \label{informal}}
328330presence or absence of prompts (\samp {>>> } and \samp {... }): to repeat
329331the example, you must type everything after the prompt, when the
330332prompt appears; lines that do not begin with a prompt are output from
331- the interpreter.%
333+ the interpreter. %
332334% \footnote{
333335% I'd prefer to use different fonts to distinguish input
334336% from output, but the amount of LaTeX hacking that would require
@@ -337,6 +339,23 @@ \chapter{An Informal Introduction to Python \label{informal}}
337339Note that a secondary prompt on a line by itself in an example means
338340you must type a blank line; this is used to end a multi-line command.
339341
342+ Many of the examples in this manual, even those entered at the
343+ interactive prompt, include comments. Comments in Python start with
344+ the hash character, \character {\# }, and extend to the end of the
345+ physical line. A comment may appear at the start of a line or
346+ following whitespace or code, but not within a string literal. A hash
347+ character within a string literal is just a hash character.
348+
349+ Some examples:
350+
351+ \begin {verbatim }
352+ # this is the first comment
353+ SPAM = 1 # and this is the second comment
354+ # ... and now a third!
355+ STRING = "# This is not a comment."
356+ \end {verbatim }
357+
358+
340359\section {Using Python as a Calculator \label {calculator } }
341360
342361Let's try some simple Python commands. Start the interpreter and wait
0 commit comments