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
077ffbb2
Commit
077ffbb2
authored
Jul 31, 2012
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finally, a coherent set of terminology for all the lil' beasties involved.
parent
c215e7e7
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
207 additions
and
174 deletions
+207
-174
Doc/glossary.rst
Doc/glossary.rst
+25
-9
Doc/reference/datamodel.rst
Doc/reference/datamodel.rst
+10
-9
Doc/reference/import.rst
Doc/reference/import.rst
+162
-149
Doc/reference/index.rst
Doc/reference/index.rst
+1
-1
Doc/reference/simple_stmts.rst
Doc/reference/simple_stmts.rst
+9
-6
No files found.
Doc/glossary.rst
View file @
077ffbb2
...
...
@@ -315,6 +315,13 @@ Glossary
role
in
places
where
a
constant
hash
value
is
needed
,
for
example
as
a
key
in
a
dictionary
.
import
path
A
list
of
locations
(
or
:
term
:`
path
entries
<
path
entry
>`)
that
are
searched
by
the
:
term
:`
path
importer
`
for
modules
to
import
.
During
import
,
this
list
of
locations
usually
comes
from
:
data
:`
sys
.
path
`,
but
for
subpackages
it
may
also
come
from
the
parent
package
's ``__path__``
attribute.
importing
The process by which Python code in one module is made available to
Python code in another module.
...
...
@@ -446,8 +453,8 @@ Glossary
meta path finder
A finder returned by a search of :data:`sys.meta_path`. Meta path
finders
are
related
to
,
but
different
from
:
term
:`
sys
path
finders
<
sy
s
path
finder
>`.
finders are related to, but different from :term:`
path entry finder
s
<path entry
finder>`.
metaclass
The class of a class. Class definitions create a class name, a class
...
...
@@ -541,9 +548,23 @@ Glossary
subpackages
.
Technically
,
a
package
is
a
Python
module
with
an
``
__path__
``
attribute
.
path
entry
A
single
location
on
the
:
term
:`
import
path
`
which
the
:
term
:`
path
importer
`
consults
to
find
modules
for
importing
.
path
entry
finder
A
:
term
:`
finder
`
returned
by
a
callable
on
:
data
:`
sys
.
path_hooks
`
(
i
.
e
.
a
:
term
:`
path
entry
hook
`)
which
knows
how
to
locate
modules
given
a
:
term
:`
path
entry
`.
path
entry
hook
A
callable
on
the
:
data
:`
sys
.
path_hook
`
list
which
returns
a
:
term
:`
path
entry
finder
`
if
it
knows
how
to
find
modules
on
a
specific
:
term
:`
path
entry
`.
path
importer
A built-in :term:`finder` / :term:`loader` that knows how to find and
load modules from the file system
.
One
of
the
default
:
term
:`
meta
path
finders
<
meta
path
finder
>`
which
searches
an
:
term
:`
import
path
`
for
modules
.
portion
A
set
of
files
in
a
single
directory
(
possibly
stored
in
a
zip
file
)
...
...
@@ -671,11 +692,6 @@ Glossary
:
meth
:`~
collections
.
somenamedtuple
.
_asdict
`.
Examples
of
struct
sequences
include
:
data
:`
sys
.
float_info
`
and
the
return
value
of
:
func
:`
os
.
stat
`.
sys path finder
A finder returned by a search of :data:`sys.path` by the :term:`path
importer`. Sys path finders are related to, but different from
:term:`meta path finders <meta path finder>`.
triple
-
quoted
string
A
string
which
is
bound
by
three
instances
of
either
a
quotation
mark
(
") or an apostrophe ('). While they don't provide any functionality
...
...
Doc/reference/datamodel.rst
View file @
077ffbb2
...
...
@@ -652,15 +652,16 @@ Modules
object: module
Modules are a basic organizational unit of Python code, and are created by
the :ref:`importmachinery` as invoked either by the :keyword:`import`
statement (see section :ref:`import`) or by calling the built in
:func:`__import__` function. A module object has a namespace implemented
by a dictionary object (this is the dictionary referenced by the
``__globals__`` attribute of functions defined in the module). Attribute
references are translated to lookups in this dictionary, e.g., ``m.x`` is
equivalent to ``m.__dict__["x"]``. A module object does not contain the
code object used to initialize the module (since it isn't needed once the
initialization is done).
the :ref:`import system <importsystem>` as invoked either by the
:keyword:`import` statement (see :keyword:`import`), or by calling
functions such as :func:`importlib.import_module` and built-in
:func:`__import__`. A module object has a namespace implemented by a
dictionary object (this is the dictionary referenced by the ``__globals__``
attribute of functions defined in the module). Attribute references are
translated to lookups in this dictionary, e.g., ``m.x`` is equivalent to
``m.__dict__["x"]``. A module object does not contain the code object used
to initialize the module (since it isn't needed once the initialization is
done).
Attribute assignment updates the module's namespace dictionary, e.g.,
``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``.
...
...
Doc/reference/import
_machinery
.rst
→
Doc/reference/import.rst
View file @
077ffbb2
This diff is collapsed.
Click to expand it.
Doc/reference/index.rst
View file @
077ffbb2
...
...
@@ -24,7 +24,7 @@ interfaces available to C/C++ programmers in detail.
lexical_analysis.rst
datamodel.rst
executionmodel.rst
import
_machinery
.rst
import.rst
expressions.rst
simple_stmts.rst
compound_stmts.rst
...
...
Doc/reference/simple_stmts.rst
View file @
077ffbb2
...
...
@@ -662,14 +662,17 @@ The :keyword:`import` statement
Import
statements
are
executed
in
two
steps
:
(
1
)
find
a
module
,
loading
and
initializing
it
if
necessary
;
(
2
)
define
a
name
or
names
in
the
local
namespace
(
of
the
scope
where
the
:
keyword
:`
import
`
statement
occurs
).
The
statement
comes
in
two
forms
differing
on
whether
it
uses
the
:
keyword
:`
from
`
keyword
.
The
first
form
(
without
:
keyword
:`
from
`)
repeats
these
steps
for
each
identifier
in
the
list
.
The
form
with
:
keyword
:`
from
`
performs
step
(
1
)
once
,
and
then
performs
step
(
2
)
repeatedly
.
namespace
(
of
the
scope
where
the
:
keyword
:`
import
`
statement
occurs
).
Step
(
1
)
may
be
performed
recursively
if
the
named
module
is
a
submodule
or
subpackage
of
a
parent
package
.
The
:
keyword
:`
import
`
statement
comes
in
two
forms
differing
on
whether
it
uses
the
:
keyword
:`
from
`
keyword
.
The
first
form
(
without
:
keyword
:`
from
`)
repeats
these
steps
for
each
identifier
in
the
list
.
The
form
with
:
keyword
:`
from
`
performs
step
(
1
),
and
then
performs
step
(
2
)
repeatedly
.
The
details
of
step
(
1
),
finding
and
loading
modules
is
described
in
greater
detail
in
the
section
on
the
:
ref
:`
import
machinery
<
importmachinery
>`,
which
detail
in
the
section
on
the
:
ref
:`
import
system
<
importsystem
>`,
which
also
describes
the
various
types
of
packages
and
modules
that
can
be
imported
,
as
well
as
all
the
hooks
that
can
be
used
to
customize
Python
's import.
...
...
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