[Zope-dev] an Interface expressing "a list of generator function"

Jim Fulton jim at zope.com
Tue Nov 9 05:11:37 EST 2010


On Tue, Nov 9, 2010 at 2:58 AM, Jean-Daniel <jeandaniel.browne at gmail.com> wrote:
> Ok,
> If I attach an item_type to the the list, I do not think I will able to use
> the native Python list, and should use a subclass instead. It is a bit
> heavyweight, especially when the intent of the use of the interface was
> documentation.

Tres could have avoided the generalization and just said something like:

class IGeneratorList(Interface):
    "A sequence of generators."

    def __getitem__(index):
        """ Return the 'index'th item.

        'index' must be an integer between 0 and __len__() - 1,
        else raise IndexError.
        """

blah blah...

Note that zope interfaces are only *semi*-formal.

> List and generators are very common in Python and are expressed in very few
> and clear characters,

Huh? What does this mean?

> I thought there would be a shorter  way to document
> their interfaces.

What exactly are you hoping to accomplish?

Jim

--
Jim Fulton


More information about the Zope-Dev mailing list