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
f2290fb1
Commit
f2290fb1
authored
May 14, 2018
by
Andrés Delfino
Committed by
Ivan Levkivskyi
May 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32769: Write annotation entry for glossary (GH-6657)
https://bugs.python.org/issue32769
parent
0ded5804
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
17 deletions
+57
-17
Doc/glossary.rst
Doc/glossary.rst
+57
-17
No files found.
Doc/glossary.rst
View file @
f2290fb1
...
@@ -39,6 +39,18 @@ Glossary
...
@@ -39,6 +39,18 @@ Glossary
and loaders (in the :mod:`importlib.abc` module). You can create your own
and loaders (in the :mod:`importlib.abc` module). You can create your own
ABCs with the :mod:`abc` module.
ABCs with the :mod:`abc` module.
annotation
A metadata value associated with a global variable, a class attribute or a
function or method parameter or return value, that stores a
:term:`type hint`.
Annotations are stored in the :attr:`__annotations__` special attribute
of a module (when annotating a global variable), class (when annotating
one of its attributes) or function or method (when annotating a parameter or a
return value) and can be accessed using :func:`typing.get_type_hints`.
See :pep:`484` and :pep:`526` which describe this functionality.
argument
argument
A value passed to a :term:`function` (or :term:`method`) when calling the
A value passed to a :term:`function` (or :term:`method`) when calling the
function. There are two kinds of argument:
function. There are two kinds of argument:
...
@@ -175,6 +187,15 @@ Glossary
...
@@ -175,6 +187,15 @@ Glossary
normally
contain
method
definitions
which
operate
on
instances
of
the
normally
contain
method
definitions
which
operate
on
instances
of
the
class
.
class
.
class
variable
A
variable
defined
in
a
class
and
intended
to
be
modified
only
at
class
level
(
i
.
e
.,
not
in
an
instance
of
the
class
).
Class
variables
can
be
specified
as
such
through
:
term
:`
type
hints
<
type
hint
>`.
See
:
pep
:`
526
`
which
describes
class
variable
annotations
.
coercion
coercion
The
implicit
conversion
of
an
instance
of
one
type
to
another
during
an
The
implicit
conversion
of
an
instance
of
one
type
to
another
during
an
operation
which
involves
two
arguments
of
the
same
type
.
For
example
,
operation
which
involves
two
arguments
of
the
same
type
.
For
example
,
...
@@ -367,16 +388,19 @@ Glossary
...
@@ -367,16 +388,19 @@ Glossary
and the :ref:`function` section.
and the :ref:`function` section.
function annotation
function annotation
An arbitrary metadata value associated with a function parameter or return
An :term:`annotation` of a function, or a method.
value. Its syntax is explained in section :ref:`function`. Annotations
may be accessed via the :attr:`__annotations__` special attribute of a
For example, this function has its parameters annotated as taking
function object.
:class:`int` arguments and its return value annotated as being an
:class:`int` as well::
def sum_two_numbers(a: int, b: int) -> int:
return a + b
See also the :term:`variable annotation` glossary entry
.
Its syntax is explained in section :ref:`function`
.
Annotations are meant to provide a standard way for programmers to
See also the :term:`variable annotation` glossary entry, and :pep:`484`,
document types of functions they design. See :pep:`484`, which
which describes this functionality.
describes this functionality.
__future__
__future__
A pseudo-module which programmers can use to enable new language features
A pseudo-module which programmers can use to enable new language features
...
@@ -1009,6 +1033,18 @@ Glossary
...
@@ -1009,6 +1033,18 @@ Glossary
:
attr
:`~
instance
.
__class__
`
attribute
or
can
be
retrieved
with
:
attr
:`~
instance
.
__class__
`
attribute
or
can
be
retrieved
with
``
type
(
obj
)``.
``
type
(
obj
)``.
type
hint
A
specification
about
the
expected
type
for
a
global
variable
,
class
variable
,
function
or
method
parameter
or
return
value
.
While
type
hints
are
optional
and
are
not
enforced
by
Python
when
used
,
they
are
useful
for
static
type
analysis
tools
,
and
aid
IDEs
on
code
completion
and
refactoring
.
Type
hints
are
stored
in
:
term
:`
annotations
<
annotation
>`.
See
also
:
pep
:`
483
`
which
describe
this
functionality
.
universal
newlines
universal
newlines
A
manner
of
interpreting
text
streams
in
which
all
of
the
following
are
A
manner
of
interpreting
text
streams
in
which
all
of
the
following
are
recognized
as
ending
a
line
:
the
Unix
end
-
of
-
line
convention
``
'\n'
``,
recognized
as
ending
a
line
:
the
Unix
end
-
of
-
line
convention
``
'\n'
``,
...
@@ -1017,17 +1053,21 @@ Glossary
...
@@ -1017,17 +1053,21 @@ Glossary
:
func
:`
bytes
.
splitlines
`
for
an
additional
use
.
:
func
:`
bytes
.
splitlines
`
for
an
additional
use
.
variable
annotation
variable
annotation
A
type
metadata
value
associated
with
a
module
global
variable
or
An
:
term
:`
annotation
`
of
a
global
variable
,
or
a
class
attribute
.
a
class
attribute
.
Its
syntax
is
explained
in
section
:
ref
:`
annassign
`.
Annotations
are
stored
in
the
:
attr
:`
__annotations__
`
special
For
example
,
this
variable
is
annotated
as
taking
:
class
:`
int
`
values
::
attribute
of
a
class
or
module
object
and
can
be
accessed
using
:
func
:`
typing
.
get_type_hints
`.
count
:
int
=
0
When
annotating
variables
,
assignment
is
optional
::
class
C
:
field
:
int
See
also
the
:
term
:`
function
annotation
`
glossary
entry
.
Its
syntax
is
explained
in
section
:
ref
:`
annassign
`
.
Annotations
are
meant
to
provide
a
standard
way
for
programmers
to
See
also
the
:
term
:`
function
annotation
`
glossary
entry
,
and
:
pep
:`
484
`
document
types
of
functions
they
design
.
See
:
pep
:`
484
`
and
:
pep
:`
526
`
and
:
pep
:`
526
`
which
describe
this
functionality
.
which
describe
this
functionality
.
virtual
environment
virtual
environment
A
cooperatively
isolated
runtime
environment
that
allows
Python
users
A
cooperatively
isolated
runtime
environment
that
allows
Python
users
...
...
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