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
aac51b8a
Commit
aac51b8a
authored
Jul 01, 2008
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add ABC to the glossary
parent
aa76d77e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
Doc/glossary.rst
Doc/glossary.rst
+12
-3
Doc/library/abc.rst
Doc/library/abc.rst
+4
-4
No files found.
Doc/glossary.rst
View file @
aac51b8a
...
@@ -24,6 +24,14 @@ Glossary
...
@@ -24,6 +24,14 @@ Glossary
2to3 is available in the standard library as :mod:`lib2to3`; a standalone
2to3 is available in the standard library as :mod:`lib2to3`; a standalone
entry point is provided as :file:`Tools/scripts/2to3`.
entry point is provided as :file:`Tools/scripts/2to3`.
Abstract Base Class
Abstract Base Classes (abbreviated ABCs) complement :term:`duck-typing` by
providing a way to define interfaces when other techniques like :func:`hasattr`
would be clumsy. Python comes with many builtin ABCs for data structures
(in the :mod:`collections` module), numbers (in the :mod:`numbers`
module), and streams (in the :mod:`io` module). You can create your own
ABC with the :mod:`abc` module.
argument
argument
A value passed to a function or method, assigned to a name local to
A value passed to a function or method, assigned to a name local to
the body. A function or method may have both positional arguments and
the body. A function or method may have both positional arguments and
...
@@ -116,15 +124,16 @@ Glossary
...
@@ -116,15 +124,16 @@ Glossary
be any object with a :meth:`__hash__` function, not just integers starting
be any object with a :meth:`__hash__` function, not just integers starting
from zero. Called a hash in Perl.
from zero. Called a hash in Perl.
duck-typing
duck-typing
Pythonic programming style that determines an object's type by inspection
Pythonic programming style that determines an object's type by inspection
of its method or attribute signature rather than by explicit relationship
of its method or attribute signature rather than by explicit relationship
to some type object ("If it looks like a duck and quacks like a duck, it
to some type object ("If it looks like a duck and quacks like a duck, it
must be a duck.") By emphasizing interfaces rather than specific types,
must be a duck.") By emphasizing interfaces rather than specific types,
well-designed code improves its flexibility by allowing polymorphic
well-designed code improves its flexibility by allowing polymorphic
substitution. Duck-typing avoids tests using :func:`type` or
substitution. Duck-typing avoids tests using :func:`type` or
:func:`isinstance`. Instead, it typically employs :func:`hasattr` tests or
:func:`isinstance`. (Note, however, that duck-typing can be complemented
:term:`EAFP` programming.
with abstract base classes.) Instead, it typically employs :func:`hasattr`
tests or :term:`EAFP` programming.
EAFP
EAFP
Easier to ask for forgiveness than permission. This common Python coding
Easier to ask for forgiveness than permission. This common Python coding
...
...
Doc/library/abc.rst
View file @
aac51b8a
...
@@ -9,10 +9,10 @@
...
@@ -9,10 +9,10 @@
.. versionadded:: 2.6
.. versionadded:: 2.6
This module provides the infrastructure for defining
abstract base classes
This module provides the infrastructure for defining
:term:`abstract base
(ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this was added
classes` (ABCs) in Python, as outlined in :pep:`3119`; see the PEP for why this
to Python. (See also :pep:`3141` and the :mod:`numbers` module regarding a typ
e
was added to Python. (See also :pep:`3141` and the :mod:`numbers` modul
e
hierarchy for numbers based on ABCs.)
regarding a type
hierarchy for numbers based on ABCs.)
The :mod:`collections` module has some concrete classes that derive from
The :mod:`collections` module has some concrete classes that derive from
ABCs; these can, of course, be further derived. In addition the
ABCs; these can, of course, be further derived. In addition the
...
...
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