[Python-checkins] python/dist/src/Doc/tut glossary.tex,1.10,1.11
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Jan 11 17:11:18 CET 2005
Update of /cvsroot/python/python/dist/src/Doc/tut
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31242
Modified Files:
glossary.tex
Log Message:
Add duck-typing to the glossary.
Index: glossary.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tut/glossary.tex,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- glossary.tex 2 Dec 2004 07:29:43 -0000 1.10
+++ glossary.tex 11 Jan 2005 16:11:13 -0000 1.11
@@ -85,6 +85,17 @@
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
More information about the Python-checkins
mailing list