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

Skip to content

Commit e991496

Browse files
committed
Merge lost revisions back
1 parent 6938f06 commit e991496

6 files changed

Lines changed: 308 additions & 262 deletions

File tree

Doc/ref/ref6.tex

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ \section{Expression statements}
2727
Expression statements are used (mostly interactively) to compute and
2828
write a value, or (usually) to call a procedure (a function that
2929
returns no meaningful result; in Python, procedures return the value
30-
\verb\None\):
30+
\verb@None@):
3131

3232
\begin{verbatim}
3333
expression_stmt: expression_list
3434
\end{verbatim}
3535

3636
An expression statement evaluates the expression list (which may be a
37-
single expression). If the value is not \verb\None\, it is converted
37+
single expression). If the value is not \verb@None@, it is converted
3838
to a string using the rules for string conversions (expressions in
3939
reverse quotes), and the resulting string is written to standard
4040
output (see section \ref{print}) on a line by itself.
@@ -45,9 +45,9 @@ \section{Expression statements}
4545
\indexii{standard}{output}
4646
\indexii{writing}{values}
4747

48-
(The exception for \verb\None\ is made so that procedure calls, which
48+
(The exception for \verb@None@ is made so that procedure calls, which
4949
are syntactically equivalent to expressions, do not cause any output.
50-
A tuple with only \verb\None\ items is written normally.)
50+
A tuple with only \verb@None@ items is written normally.)
5151
\indexii{procedure}{call}
5252

5353
\section{Assignment statements}
@@ -114,7 +114,7 @@ \section{Assignment statements}
114114
\begin{itemize}
115115

116116
\item
117-
If the name does not occur in a \verb\global\ statement in the current
117+
If the name does not occur in a \verb@global@ statement in the current
118118
code block: the name is bound to the object in the current local name
119119
space.
120120
\stindex{global}
@@ -140,10 +140,10 @@ \section{Assignment statements}
140140
\item
141141
If the target is an attribute reference: The primary expression in the
142142
reference is evaluated. It should yield an object with assignable
143-
attributes; if this is not the case, \verb\TypeError\ is raised. That
143+
attributes; if this is not the case, \verb@TypeError@ is raised. That
144144
object is then asked to assign the assigned object to the given
145145
attribute; if it cannot perform the assignment, it raises an exception
146-
(usually but not necessarily \verb\AttributeError\).
146+
(usually but not necessarily \verb@AttributeError@).
147147
\indexii{attribute}{assignment}
148148

149149
\item
@@ -159,7 +159,7 @@ \section{Assignment statements}
159159
is added to it. The resulting value must be a nonnegative integer
160160
less than the sequence's length, and the sequence is asked to assign
161161
the assigned object to its item with that index. If the index is out
162-
of range, \verb\IndexError\ is raised (assignment to a subscripted
162+
of range, \verb@IndexError@ is raised (assignment to a subscripted
163163
sequence cannot add new items to a list).
164164
\obindex{sequence}
165165
\obindex{list}
@@ -175,16 +175,17 @@ \section{Assignment statements}
175175

176176
\item
177177
If the target is a slicing: The primary expression in the reference is
178-
evaluated. It should yield a mutable sequence (list) object. The
178+
evaluated. It should yield a mutable sequence object (e.g. a list). The
179179
assigned object should be a sequence object of the same type. Next,
180180
the lower and upper bound expressions are evaluated, insofar they are
181181
present; defaults are zero and the sequence's length. The bounds
182182
should evaluate to (small) integers. If either bound is negative, the
183183
sequence's length is added to it. The resulting bounds are clipped to
184184
lie between zero and the sequence's length, inclusive. Finally, the
185-
sequence object is asked to replace the items indicated by the slice
186-
with the items of the assigned sequence. This may change the
187-
sequence's length, if it allows it.
185+
sequence object is asked to replace the slice with the items of the
186+
assigned sequence. The length of the slice may be different from the
187+
length of the assigned sequence, thus changing the length of the
188+
target sequence, if the object allows it.
188189
\indexii{slicing}{assignment}
189190

190191
\end{itemize}
@@ -201,7 +202,7 @@ \section{The {\tt pass} statement}
201202
pass_stmt: "pass"
202203
\end{verbatim}
203204

204-
\verb\pass\ is a null operation --- when it is executed, nothing
205+
\verb@pass@ is a null operation --- when it is executed, nothing
205206
happens. It is useful as a placeholder when a statement is
206207
required syntactically, but no code needs to be executed, for example:
207208
\indexii{null}{operation}
@@ -230,7 +231,7 @@ \section{The {\tt del} statement}
230231

231232
Deletion of a name removes the binding of that name (which must exist)
232233
from the local or global name space, depending on whether the name
233-
occurs in a \verb\global\ statement in the same code block.
234+
occurs in a \verb@global@ statement in the same code block.
234235
\stindex{global}
235236
\indexii{unbinding}{name}
236237

@@ -247,7 +248,7 @@ \section{The {\tt print} statement} \label{print}
247248
print_stmt: "print" [ condition ("," condition)* [","] ]
248249
\end{verbatim}
249250

250-
\verb\print\ evaluates each condition in turn and writes the resulting
251+
\verb@print@ evaluates each condition in turn and writes the resulting
251252
object to standard output (see below). If an object is not a string,
252253
it is first converted to a string using the rules for string
253254
conversions. The (resulting or original) string is then written. A
@@ -256,21 +257,21 @@ \section{The {\tt print} statement} \label{print}
256257
line. This is the case: (1) when no characters have yet been written
257258
to standard output; or (2) when the last character written to standard
258259
output is \verb/\n/; or (3) when the last write operation on standard
259-
output was not a \verb\print\ statement. (In some cases it may be
260+
output was not a \verb@print@ statement. (In some cases it may be
260261
functional to write an empty string to standard output for this
261262
reason.)
262263
\index{output}
263264
\indexii{writing}{values}
264265

265-
A \verb/"\n"/ character is written at the end, unless the \verb\print\
266+
A \verb/"\n"/ character is written at the end, unless the \verb@print@
266267
statement ends with a comma. This is the only action if the statement
267-
contains just the keyword \verb\print\.
268+
contains just the keyword \verb@print@.
268269
\indexii{trailing}{comma}
269270
\indexii{newline}{suppression}
270271

271-
Standard output is defined as the file object named \verb\stdout\
272-
in the built-in module \verb\sys\. If no such object exists,
273-
or if it is not a writable file, a \verb\RuntimeError\ exception is raised.
272+
Standard output is defined as the file object named \verb@stdout@
273+
in the built-in module \verb@sys@. If no such object exists,
274+
or if it is not a writable file, a \verb@RuntimeError@ exception is raised.
274275
(The original implementation attempts to write to the system's original
275276
standard output instead, but this is not safe, and should be fixed.)
276277
\indexii{standard}{output}
@@ -285,19 +286,19 @@ \section{The {\tt return} statement}
285286
return_stmt: "return" [condition_list]
286287
\end{verbatim}
287288

288-
\verb\return\ may only occur syntactically nested in a function
289+
\verb@return@ may only occur syntactically nested in a function
289290
definition, not within a nested class definition.
290291
\indexii{function}{definition}
291292
\indexii{class}{definition}
292293

293-
If a condition list is present, it is evaluated, else \verb\None\
294+
If a condition list is present, it is evaluated, else \verb@None@
294295
is substituted.
295296

296-
\verb\return\ leaves the current function call with the condition
297-
list (or \verb\None\) as return value.
297+
\verb@return@ leaves the current function call with the condition
298+
list (or \verb@None@) as return value.
298299

299-
When \verb\return\ passes control out of a \verb\try\ statement
300-
with a \verb\finally\ clause, that finally clause is executed
300+
When \verb@return@ passes control out of a \verb@try@ statement
301+
with a \verb@finally@ clause, that finally clause is executed
301302
before really leaving the function.
302303
\kwindex{finally}
303304

@@ -308,14 +309,14 @@ \section{The {\tt raise} statement}
308309
raise_stmt: "raise" condition ["," condition]
309310
\end{verbatim}
310311

311-
\verb\raise\ evaluates its first condition, which must yield
312+
\verb@raise@ evaluates its first condition, which must yield
312313
a string object. If there is a second condition, this is evaluated,
313-
else \verb\None\ is substituted.
314+
else \verb@None@ is substituted.
314315
\index{exception}
315316
\indexii{raising}{exception}
316317

317318
It then raises the exception identified by the first object,
318-
with the second one (or \verb\None\) as its parameter.
319+
with the second one (or \verb@None@) as its parameter.
319320

320321
\section{The {\tt break} statement}
321322
\stindex{break}
@@ -324,22 +325,23 @@ \section{The {\tt break} statement}
324325
break_stmt: "break"
325326
\end{verbatim}
326327

327-
\verb\break\ may only occur syntactically nested in a \verb\for\
328-
or \verb\while\ loop, not nested in a function or class definition.
328+
\verb@break@ may only occur syntactically nested in a \verb@for@
329+
or \verb@while@ loop, but not nested in a function or class definition
330+
within that loop.
329331
\stindex{for}
330332
\stindex{while}
331333
\indexii{loop}{statement}
332334

333-
It terminates the neares enclosing loop, skipping the optional
334-
\verb\else\ clause if the loop has one.
335+
It terminates the nearest enclosing loop, skipping the optional
336+
\verb@else@ clause if the loop has one.
335337
\kwindex{else}
336338

337-
If a \verb\for\ loop is terminated by \verb\break\, the loop control
339+
If a \verb@for@ loop is terminated by \verb@break@, the loop control
338340
target keeps its current value.
339341
\indexii{loop control}{target}
340342

341-
When \verb\break\ passes control out of a \verb\try\ statement
342-
with a \verb\finally\ clause, that finally clause is executed
343+
When \verb@break@ passes control out of a \verb@try@ statement
344+
with a \verb@finally@ clause, that finally clause is executed
343345
before really leaving the loop.
344346
\kwindex{finally}
345347

@@ -350,11 +352,10 @@ \section{The {\tt continue} statement}
350352
continue_stmt: "continue"
351353
\end{verbatim}
352354

353-
\verb\continue\ may only occur syntactically nested in a \verb\for\ or
354-
\verb\while\ loop, not nested in a function or class definition, and
355-
not nested in the \verb\try\ clause of a \verb\try\ statement with a
356-
\verb\finally\ clause (it may occur nested in a \verb\except\ or
357-
\verb\finally\ clause of a \verb\try\ statement though).
355+
\verb@continue@ may only occur syntactically nested in a \verb@for@ or
356+
\verb@while@ loop, but not nested in a function or class definition or
357+
\verb@try@ statement within that loop.\footnote{Except that it may
358+
currently occur within an \verb@except@ clause.}
358359
\stindex{for}
359360
\stindex{while}
360361
\indexii{loop}{statement}
@@ -373,25 +374,25 @@ \section{The {\tt import} statement} \label{import}
373374

374375
Import statements are executed in two steps: (1) find a module, and
375376
initialize it if necessary; (2) define a name or names in the local
376-
name space (of the scope where the \verb\import\ statement occurs).
377-
The first form (without \verb\from\) repeats these steps for each
378-
identifier in the list, the \verb\from\ form performs them once, with
377+
name space (of the scope where the \verb@import@ statement occurs).
378+
The first form (without \verb@from@) repeats these steps for each
379+
identifier in the list, the \verb@from@ form performs them once, with
379380
the first identifier specifying the module name.
380381
\indexii{importing}{module}
381382
\indexii{name}{binding}
382383
\kwindex{from}
383384

384385
The system maintains a table of modules that have been initialized,
385386
indexed by module name. (The current implementation makes this table
386-
accessible as \verb\sys.modules\.) When a module name is found in
387+
accessible as \verb@sys.modules@.) When a module name is found in
387388
this table, step (1) is finished. If not, a search for a module
388389
definition is started. This first looks for a built-in module
389390
definition, and if no built-in module if the given name is found, it
390391
searches a user-specified list of directories for a file whose name is
391-
the module name with extension \verb\".py"\. (The current
392-
implementation uses the list of strings \verb\sys.path\ as the search
392+
the module name with extension \verb@".py"@. (The current
393+
implementation uses the list of strings \verb@sys.path@ as the search
393394
path; it is initialized from the shell environment variable
394-
\verb\$PYTHONPATH\, with an installation-dependent default.)
395+
\verb@$PYTHONPATH@, with an installation-dependent default.)
395396
\ttindex{modules}
396397
\ttindex{sys.modules}
397398
\indexii{module}{name}
@@ -404,9 +405,9 @@ \section{The {\tt import} statement} \label{import}
404405

405406
If a built-in module is found, its built-in initialization code is
406407
executed and step (1) is finished. If no matching file is found,
407-
\verb\ImportError\ is raised. If a file is found, it is parsed,
408+
\verb@ImportError@ is raised. If a file is found, it is parsed,
408409
yielding an executable code block. If a syntax error occurs,
409-
\verb\SyntaxError\ is raised. Otherwise, an empty module of the given
410+
\verb@SyntaxError@ is raised. Otherwise, an empty module of the given
410411
name is created and inserted in the module table, and then the code
411412
block is executed in the context of this module. Exceptions during
412413
this execution terminate step (1).
@@ -418,23 +419,23 @@ \section{The {\tt import} statement} \label{import}
418419
When step (1) finishes without raising an exception, step (2) can
419420
begin.
420421

421-
The first form of \verb\import\ statement binds the module name in the
422+
The first form of \verb@import@ statement binds the module name in the
422423
local name space to the module object, and then goes on to import the
423-
next identifier, if any. The \verb\from\ from does not bind the
424+
next identifier, if any. The \verb@from@ from does not bind the
424425
module name: it goes through the list of identifiers, looks each one
425426
of them up in the module found in step (1), and binds the name in the
426427
local name space to the object thus found. If a name is not found,
427-
\verb\ImportError\ is raised. If the list of identifiers is replaced
428-
by a star (\verb\*\), all names defined in the module are bound,
429-
except those beginning with an underscore(\verb\_\).
428+
\verb@ImportError@ is raised. If the list of identifiers is replaced
429+
by a star (\verb@*@), all names defined in the module are bound,
430+
except those beginning with an underscore(\verb@_@).
430431
\indexii{name}{binding}
431432
\exindex{ImportError}
432433

433-
Names bound by import statements may not occur in \verb\global\
434+
Names bound by import statements may not occur in \verb@global@
434435
statements in the same scope.
435436
\stindex{global}
436437

437-
The \verb\from\ form with \verb\*\ may only occur in a module scope.
438+
The \verb@from@ form with \verb@*@ may only occur in a module scope.
438439
\kwindex{from}
439440
\ttindex{from ... import *}
440441

@@ -450,19 +451,19 @@ \section{The {\tt global} statement} \label{global}
450451
global_stmt: "global" identifier ("," identifier)*
451452
\end{verbatim}
452453

453-
The \verb\global\ statement is a declaration which holds for the
454+
The \verb@global@ statement is a declaration which holds for the
454455
entire current scope. It means that the listed identifiers are to be
455456
interpreted as globals. While {\em using} global names is automatic
456457
if they are not defined in the local scope, {\em assigning} to global
457-
names would be impossible without \verb\global\.
458+
names would be impossible without \verb@global@.
458459
\indexiii{global}{name}{binding}
459460

460-
Names listed in a \verb\global\ statement must not be used in the same
461-
scope before that \verb\global\ statement is executed.
461+
Names listed in a \verb@global@ statement must not be used in the same
462+
scope before that \verb@global@ statement is executed.
462463

463-
Names listed in a \verb\global\ statement must not be defined as formal
464-
parameters or in a \verb\for\ loop control target, \verb\class\
465-
definition, function definition, or \verb\import\ statement.
464+
Names listed in a \verb@global@ statement must not be defined as formal
465+
parameters or in a \verb@for@ loop control target, \verb@class@
466+
definition, function definition, or \verb@import@ statement.
466467

467468
(The current implementation does not enforce the latter two
468469
restrictions, but programs should not abuse this freedom, as future
@@ -478,7 +479,7 @@ \section{The {\tt access} statement} \label{access}
478479

479480
This statement will be used in the future to control access to
480481
instance and class variables. Currently its syntax and effects are
481-
undefined; however the keyword \verb\access\ is a reserved word for
482+
undefined; however the keyword \verb@access@ is a reserved word for
482483
the parser.
483484

484485
\section{The {\tt exec} statement} \label{exec}
@@ -496,12 +497,12 @@ \section{The {\tt exec} statement} \label{exec}
496497
executed. If it is a code object, it is simply executed.
497498

498499
In all cases, if the optional parts are omitted, the code is executed
499-
in the current scope. If only the first expression after \verb\in\ is
500+
in the current scope. If only the first expression after \verb@in@ is
500501
specified, it should be a dictionary, which will be used for both the
501502
global and the local variables. If two expressions are given, both
502503
must be dictionaries and they are used for the global and local
503504
variables, respectively.
504505

505506
Note: dynamic evaluation of expressions is supported by the built-in
506-
function \verb\eval\.
507+
function \verb@eval@.
507508

0 commit comments

Comments
 (0)