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
d4f5b07e
Commit
d4f5b07e
authored
Jan 11, 2005
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add duck-typing to the glossary.
parent
faa10ebd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
Doc/tut/glossary.tex
Doc/tut/glossary.tex
+11
-0
No files found.
Doc/tut/glossary.tex
View file @
d4f5b07e
...
...
@@ -85,6 +85,17 @@ use of \class{dict} much resembles that for \class{list}, but the keys
can be any object with a
\method
{__
hash
__
()
}
function, not just
integers starting from zero. Called a hash in Perl.
\index
{
duck-typing
}
\item
{
duck-typing
}
Pythonic programming style that determines an object's type by inspection
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
must be a duck.") By emphasizing interfaces rather than specific types,
well-designed code improves its flexibility by allowing polymorphic
substitution. Duck-typing avoids tests using
\function
{
type()
}
or
\function
{
isinstance()
}
. Instead, it typically employs
\function
{
hasattr()
}
tests or
{}
\emph
{
EAFP
}
programming.
\index
{
EAFP
}
\item
[EAFP]
Easier to ask for forgiveness than permission. This common Python
...
...
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