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

Jean-Daniel jeandaniel.browne at gmail.com
Mon Nov 8 04:40:47 EST 2010


Hello,

I have two objects which interoperate to solve a sudoku: the Sudoku class
and a vector (a list actually) of generator functions. The Sudoku interface
is simple to write as it requires three functions and an attribute.

class ISudoku:

    board = Attribute()

    def free(col, line):
        "frees the slot at position col, line"

    def set(col, line, value):
        "Sets the value in the slot at position col, line"

    def candidates(col, line):
        "Returns the candidate digits for the slot at position col,line"


But how to express "vector of generator functions" with Zope interfaces? I
want to express the possibility to access the vector object with
the  [n] index notation, and this returns a function returning a generator
(an object with an iter and next function).

Thank you for your help,


PS: the vector of generator functions is the input of the algorithm called
"conjoin", used to solve the eight queen problem and knight's tour problem.
It is described in the Python sources
(Python-2.6.5/Lib/test/test_generators.py).

PPS: I say vector instead of list even when the vector is a list, because
"list" usually  implies the possibility to append elements dynamically which
is not pertinent in this problem. The length of the vector won't change and
is equal to the number of slots on a sudoku board.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.zope.org/pipermail/zope-dev/attachments/20101108/ec5bd32a/attachment.html 


More information about the Zope-Dev mailing list