[Types-sig] Protocols

Paul Prescod paulp@ActiveState.com
Wed, 14 Mar 2001 05:54:55 -0800

Michel Pelletier wrote:
> This is what I think about what thinking about bringing types to python:
> to me, protocol means the same thing as interface.  Is this off-base?

No, I think that most people use the words interchangably.

> > The minimalist spirit is to lean towards "too lightweight." Therefore I
> > propose that the protocol for mappings require only __getattr__,
> > .keys(), .values() and .items(). The protocol for sequences requires
> > only __getattr__.
> Really?  Defining a sequence as getattr seems to broad to me.  To me,
> something that only implements getattr is an object.  Of course, this
> doesn't work for types, which are objects.  I would think a sequence was
> defined by __len__ and __getitem__.

Doh! I meant __getitem__. I'm not sure about __len__ . There are such
things as infinite sequences. 

> We've made a couple of guesses along these lines, should I post them for
> discussion?

Yes please!

    Programming the way
    indented it.
       - (originated with Skip Montanaro?)