Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdadf0f

Browse files
committed
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 <[email protected]>.
1 parent 0e1de8b commit bdadf0f

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

Doc/tut/tut.tex

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
287287
beginning 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}}
328330
presence or absence of prompts (\samp{>>> } and \samp{... }): to repeat
329331
the example, you must type everything after the prompt, when the
330332
prompt 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}}
337339
Note that a secondary prompt on a line by itself in an example means
338340
you 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

342361
Let's try some simple Python commands. Start the interpreter and wait

0 commit comments

Comments
 (0)