Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
611be707
Commit
611be707
authored
Jul 07, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace vars() with locals() and globals(); 3rd raise arg; typos
parent
8fd02194
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
38 deletions
+56
-38
Doc/ref/ref4.tex
Doc/ref/ref4.tex
+6
-5
Doc/ref/ref6.tex
Doc/ref/ref6.tex
+22
-14
Doc/ref4.tex
Doc/ref4.tex
+6
-5
Doc/ref6.tex
Doc/ref6.tex
+22
-14
No files found.
Doc/ref/ref4.tex
View file @
611be707
...
@@ -125,13 +125,14 @@ overridden with optional extra arguments.
...
@@ -125,13 +125,14 @@ overridden with optional extra arguments.
\end{description}
\end{description}
The built-in function
\verb
@
vars()
@
returns a dictionary representing
The built-in functions
\verb
@
globals()
@
and
\verb
@
locals()
@
returns a
the current local name space. The effect of modifications to this
dictionary representing the current global and local name space,
dictionary on the name space are undefined.
%
respectively. The effect of modifications to this dictionary on the
\footnote
{
The current implementation returns the dictionary actually
name space are undefined.
%
\footnote
{
The current implementations return the dictionary actually
used to implement the name space,
{
\em
except
}
for functions, where
used to implement the name space,
{
\em
except
}
for functions, where
the optimizer may cause the local name space to be implemented
the optimizer may cause the local name space to be implemented
differently.
}
differently
, and
\verb
@
locals()
@
returns a read-only dictionary
.
}
\section
{
Exceptions
}
\section
{
Exceptions
}
...
...
Doc/ref/ref6.tex
View file @
611be707
...
@@ -30,24 +30,24 @@ returns no meaningful result; in Python, procedures return the value
...
@@ -30,24 +30,24 @@ returns no meaningful result; in Python, procedures return the value
\verb
@
None
@
):
\verb
@
None
@
):
\begin{verbatim}
\begin{verbatim}
expression
_
stmt:
express
ion
_
list
expression
_
stmt:
condit
ion
_
list
\end{verbatim}
\end{verbatim}
An expression statement evaluates the expression list (which may be a
An expression statement evaluates the condition list (which may be a
single expression). If the value is not
\verb
@
None
@
, it is converted
single condition).
\indexii
{
expression
}{
list
}
In interactive mode, if the value is not
\verb
@
None
@
, it is converted
to a string using the rules for string conversions (expressions in
to a string using the rules for string conversions (expressions in
reverse quotes), and the resulting string is written to standard
reverse quotes), and the resulting string is written to standard
output (see section
\ref
{
print
}
) on a line by itself.
output (see section
\ref
{
print
}
) on a line by itself.
\indexii
{
expression
}{
list
}
(The exception for
\verb
@
None
@
is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.)
\ttindex
{
None
}
\ttindex
{
None
}
\indexii
{
string
}{
conversion
}
\indexii
{
string
}{
conversion
}
\index
{
output
}
\index
{
output
}
\indexii
{
standard
}{
output
}
\indexii
{
standard
}{
output
}
\indexii
{
writing
}{
values
}
\indexii
{
writing
}{
values
}
(The exception for
\verb
@
None
@
is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.
A tuple with only
\verb
@
None
@
items is written normally.)
\indexii
{
procedure
}{
call
}
\indexii
{
procedure
}{
call
}
\section
{
Assignment statements
}
\section
{
Assignment statements
}
...
@@ -224,7 +224,7 @@ required syntactically, but no code needs to be executed, for example:
...
@@ -224,7 +224,7 @@ required syntactically, but no code needs to be executed, for example:
\begin{verbatim}
\begin{verbatim}
def f(arg): pass # a function that does nothing (yet)
def f(arg): pass # a function that does nothing (yet)
class C: pass # a
n
class with no methods (yet)
class C: pass # a class with no methods (yet)
\end{verbatim}
\end{verbatim}
\section
{
The
{
\tt
del
}
statement
}
\section
{
The
{
\tt
del
}
statement
}
...
@@ -320,7 +320,7 @@ before really leaving the function.
...
@@ -320,7 +320,7 @@ before really leaving the function.
\stindex
{
raise
}
\stindex
{
raise
}
\begin{verbatim}
\begin{verbatim}
raise
_
stmt: "raise" condition ["," condition]
raise
_
stmt: "raise" condition ["," condition
["," condition]
]
\end{verbatim}
\end{verbatim}
\verb
@
raise
@
evaluates its first condition, which must yield
\verb
@
raise
@
evaluates its first condition, which must yield
...
@@ -337,7 +337,15 @@ If the first object is a class or string, it then raises the exception
...
@@ -337,7 +337,15 @@ If the first object is a class or string, it then raises the exception
identified by the first object, with the second one (or
\verb
@
None
@
)
identified by the first object, with the second one (or
\verb
@
None
@
)
as its parameter. If the first object is an instance, it raises the
as its parameter. If the first object is an instance, it raises the
exception identified by the class of the object, with the instance as
exception identified by the class of the object, with the instance as
its parameter.
its parameter (and there should be no second object, or the second
object should be
\verb
@
None
@
).
If a third object is present, and it it not
\verb
@
None
@
, it should be
a traceback object (see section
\ref
{
traceback
}
), and it is
substituted instead of the current location as the place where the
exception occurred. This is useful to re-raise an exception
transparently in an except clause.
\obindex
{
traceback
}
\section
{
The
{
\tt
break
}
statement
}
\section
{
The
{
\tt
break
}
statement
}
\stindex
{
break
}
\stindex
{
break
}
...
@@ -525,6 +533,6 @@ must be dictionaries and they are used for the global and local
...
@@ -525,6 +533,6 @@ must be dictionaries and they are used for the global and local
variables, respectively.
variables, respectively.
Hints: dynamic evaluation of expressions is supported by the built-in
Hints: dynamic evaluation of expressions is supported by the built-in
function
\verb
@
eval()
@
. The built-in function
\verb
@
vars()
@
returns
function
\verb
@
eval()
@
. The built-in function
s
\verb
@
globals()
@
and
the current local dictionary, which may be useful to pass around for
\verb
@
locals()
@
return the current global and local dictionary,
use by
\verb
@
exec
@
.
respectively, which may be useful to pass around for
use by
\verb
@
exec
@
.
Doc/ref4.tex
View file @
611be707
...
@@ -125,13 +125,14 @@ overridden with optional extra arguments.
...
@@ -125,13 +125,14 @@ overridden with optional extra arguments.
\end{description}
\end{description}
The built-in function
\verb
@
vars()
@
returns a dictionary representing
The built-in functions
\verb
@
globals()
@
and
\verb
@
locals()
@
returns a
the current local name space. The effect of modifications to this
dictionary representing the current global and local name space,
dictionary on the name space are undefined.
%
respectively. The effect of modifications to this dictionary on the
\footnote
{
The current implementation returns the dictionary actually
name space are undefined.
%
\footnote
{
The current implementations return the dictionary actually
used to implement the name space,
{
\em
except
}
for functions, where
used to implement the name space,
{
\em
except
}
for functions, where
the optimizer may cause the local name space to be implemented
the optimizer may cause the local name space to be implemented
differently.
}
differently
, and
\verb
@
locals()
@
returns a read-only dictionary
.
}
\section
{
Exceptions
}
\section
{
Exceptions
}
...
...
Doc/ref6.tex
View file @
611be707
...
@@ -30,24 +30,24 @@ returns no meaningful result; in Python, procedures return the value
...
@@ -30,24 +30,24 @@ returns no meaningful result; in Python, procedures return the value
\verb
@
None
@
):
\verb
@
None
@
):
\begin{verbatim}
\begin{verbatim}
expression
_
stmt:
express
ion
_
list
expression
_
stmt:
condit
ion
_
list
\end{verbatim}
\end{verbatim}
An expression statement evaluates the expression list (which may be a
An expression statement evaluates the condition list (which may be a
single expression). If the value is not
\verb
@
None
@
, it is converted
single condition).
\indexii
{
expression
}{
list
}
In interactive mode, if the value is not
\verb
@
None
@
, it is converted
to a string using the rules for string conversions (expressions in
to a string using the rules for string conversions (expressions in
reverse quotes), and the resulting string is written to standard
reverse quotes), and the resulting string is written to standard
output (see section
\ref
{
print
}
) on a line by itself.
output (see section
\ref
{
print
}
) on a line by itself.
\indexii
{
expression
}{
list
}
(The exception for
\verb
@
None
@
is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.)
\ttindex
{
None
}
\ttindex
{
None
}
\indexii
{
string
}{
conversion
}
\indexii
{
string
}{
conversion
}
\index
{
output
}
\index
{
output
}
\indexii
{
standard
}{
output
}
\indexii
{
standard
}{
output
}
\indexii
{
writing
}{
values
}
\indexii
{
writing
}{
values
}
(The exception for
\verb
@
None
@
is made so that procedure calls, which
are syntactically equivalent to expressions, do not cause any output.
A tuple with only
\verb
@
None
@
items is written normally.)
\indexii
{
procedure
}{
call
}
\indexii
{
procedure
}{
call
}
\section
{
Assignment statements
}
\section
{
Assignment statements
}
...
@@ -224,7 +224,7 @@ required syntactically, but no code needs to be executed, for example:
...
@@ -224,7 +224,7 @@ required syntactically, but no code needs to be executed, for example:
\begin{verbatim}
\begin{verbatim}
def f(arg): pass # a function that does nothing (yet)
def f(arg): pass # a function that does nothing (yet)
class C: pass # a
n
class with no methods (yet)
class C: pass # a class with no methods (yet)
\end{verbatim}
\end{verbatim}
\section
{
The
{
\tt
del
}
statement
}
\section
{
The
{
\tt
del
}
statement
}
...
@@ -320,7 +320,7 @@ before really leaving the function.
...
@@ -320,7 +320,7 @@ before really leaving the function.
\stindex
{
raise
}
\stindex
{
raise
}
\begin{verbatim}
\begin{verbatim}
raise
_
stmt: "raise" condition ["," condition]
raise
_
stmt: "raise" condition ["," condition
["," condition]
]
\end{verbatim}
\end{verbatim}
\verb
@
raise
@
evaluates its first condition, which must yield
\verb
@
raise
@
evaluates its first condition, which must yield
...
@@ -337,7 +337,15 @@ If the first object is a class or string, it then raises the exception
...
@@ -337,7 +337,15 @@ If the first object is a class or string, it then raises the exception
identified by the first object, with the second one (or
\verb
@
None
@
)
identified by the first object, with the second one (or
\verb
@
None
@
)
as its parameter. If the first object is an instance, it raises the
as its parameter. If the first object is an instance, it raises the
exception identified by the class of the object, with the instance as
exception identified by the class of the object, with the instance as
its parameter.
its parameter (and there should be no second object, or the second
object should be
\verb
@
None
@
).
If a third object is present, and it it not
\verb
@
None
@
, it should be
a traceback object (see section
\ref
{
traceback
}
), and it is
substituted instead of the current location as the place where the
exception occurred. This is useful to re-raise an exception
transparently in an except clause.
\obindex
{
traceback
}
\section
{
The
{
\tt
break
}
statement
}
\section
{
The
{
\tt
break
}
statement
}
\stindex
{
break
}
\stindex
{
break
}
...
@@ -525,6 +533,6 @@ must be dictionaries and they are used for the global and local
...
@@ -525,6 +533,6 @@ must be dictionaries and they are used for the global and local
variables, respectively.
variables, respectively.
Hints: dynamic evaluation of expressions is supported by the built-in
Hints: dynamic evaluation of expressions is supported by the built-in
function
\verb
@
eval()
@
. The built-in function
\verb
@
vars()
@
returns
function
\verb
@
eval()
@
. The built-in function
s
\verb
@
globals()
@
and
the current local dictionary, which may be useful to pass around for
\verb
@
locals()
@
return the current global and local dictionary,
use by
\verb
@
exec
@
.
respectively, which may be useful to pass around for
use by
\verb
@
exec
@
.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment