[Python-checkins] python/dist/src/Doc/tut glossary.tex, 1.9.4.1,
1.9.4.2
rhettinger at users.sourceforge.net
rhettinger at users.sourceforge.net
Tue Jan 11 17:14:58 CET 2005
Update of /cvsroot/python/python/dist/src/Doc/tut
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32405
Modified Files:
Tag: release24-maint
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.9.4.1
retrieving revision 1.9.4.2
diff -u -d -r1.9.4.1 -r1.9.4.2
--- glossary.tex 2 Dec 2004 08:57:19 -0000 1.9.4.1
+++ glossary.tex 11 Jan 2005 16:14:55 -0000 1.9.4.2
@@ -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