The term "Protocol"

Robert Brewer fumanchu at amor.org
Sun Aug 1 21:49:41 EDT 2004


Bruce Eckel wrote:
> Sunday, August 1, 2004, 6:51:15 PM, Tim Peters wrote:
> 
> > Iteration is a protocol, not a type.
> 
> I know the term "protocol" has been used to describe a language
> feature in a number of languages, but since we have no official
> "protocol" support in Python I'm interested in what "we" mean by this
> term. I'm going to guess that a protocol is like an interface in Java,
> except that it doesn't have a concrete definition anywhere, but it is
> implied through convention and use. Thus a protocol is a "latent
> interface." Am I close? I'd like to understand this term better.

In my (short) experience with the Python community, I've found that
Pythonistas use the term "protocol" to mean a convention which is stated
in the docs, as opposed to enforced via syntax. In the case of iter,
your object either responds to those calls (__iter__ and next) or it
does not--no inspection (or enforcement) of class or signature
necessary. Note that this does *not* imply that a protocol "doesn't have
a concrete definition". Python simply lands on the side of convention
more often than many of what are called the "B&D" languages (which love
to enforce convention in syntax), and technical terms like "protocol"
naturally get bent to accomodate that. ;)


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list