Ok, <div><br></div><div>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.<br>
<div><br></div><div>List and generators are very common in Python and are expressed in very few and clear characters, I thought there would be a shorter  way to document their interfaces.</div><div><br></div><div>Thank you,</div>
<div><br><br><div class="gmail_quote">On Mon, Nov 8, 2010 at 2:24 PM, Tres Seaver <span dir="ltr">&lt;<a href="mailto:tseaver@palladion.com">tseaver@palladion.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
-----BEGIN PGP SIGNED MESSAGE-----<br>
Hash: SHA1<br>
<div><div></div><div class="h5"><br>
On 11/08/2010 04:40 AM, Jean-Daniel wrote:<br>
&gt; Hello,<br>
&gt;<br>
&gt; I have two objects which interoperate to solve a sudoku: the Sudoku class<br>
&gt; and a vector (a list actually) of generator functions. The Sudoku interface<br>
&gt; is simple to write as it requires three functions and an attribute.<br>
&gt;<br>
&gt; class ISudoku:<br>
&gt;<br>
&gt;     board = Attribute()<br>
&gt;<br>
&gt;     def free(col, line):<br>
&gt;         &quot;frees the slot at position col, line&quot;<br>
&gt;<br>
&gt;     def set(col, line, value):<br>
&gt;         &quot;Sets the value in the slot at position col, line&quot;<br>
&gt;<br>
&gt;     def candidates(col, line):<br>
&gt;         &quot;Returns the candidate digits for the slot at position col,line&quot;<br>
&gt;<br>
&gt;<br>
&gt; But how to express &quot;vector of generator functions&quot; with Zope interfaces? I<br>
&gt; want to express the possibility to access the vector object with<br>
&gt; the  [n] index notation, and this returns a function returning a generator<br>
&gt; (an object with an iter and next function).<br>
&gt;<br>
&gt; Thank you for your help,<br>
&gt;<br>
&gt;<br>
&gt; PS: the vector of generator functions is the input of the algorithm called<br>
&gt; &quot;conjoin&quot;, used to solve the eight queen problem and knight&#39;s tour problem.<br>
&gt; It is described in the Python sources<br>
&gt; (Python-2.6.5/Lib/test/test_generators.py).<br>
&gt;<br>
&gt; PPS: I say vector instead of list even when the vector is a list, because<br>
&gt; &quot;list&quot; usually  implies the possibility to append elements dynamically which<br>
&gt; is not pertinent in this problem. The length of the vector won&#39;t change and<br>
&gt; is equal to the number of slots on a sudoku board.<br>
<br>
<br>
</div></div>I would specify the contracts omething like so::<br>
<br>
<br>
class IVector(Interface):<br>
<br>
    item_type = Attribute(u&quot;Interface of items.&quot;)<br>
<br>
    def __len__():<br>
        &quot;&quot;&quot; Fixed length of vector.<br>
        &quot;&quot;&quot;<br>
<br>
    def __getitem__(index):<br>
        &quot;&quot;&quot; Return the &#39;index&#39;th item.<br>
<br>
        Items conform to &#39;item_type&#39;.<br>
<br>
        &#39;index&#39; must be an integer between 0 and __len__() - 1,<br>
        else raise IndexError.<br>
        &quot;&quot;&quot;<br>
<br>
class IIterable(Interface):<br>
<br>
    def __iter__():<br>
        &quot;&quot;&quot; Return an iterator for this object.<br>
        &quot;&quot;&quot;<br>
<br>
<br>
<br>
<br>
- --<br>
===================================================================<br>
Tres Seaver          +1 540-429-0999          <a href="mailto:tseaver@palladion.com">tseaver@palladion.com</a><br>
Palladion Software   &quot;Excellence by Design&quot;    <a href="http://palladion.com" target="_blank">http://palladion.com</a><br>
-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.10 (GNU/Linux)<br>
Comment: Using GnuPG with Mozilla - <a href="http://enigmail.mozdev.org/" target="_blank">http://enigmail.mozdev.org/</a><br>
<br>
iEYEARECAAYFAkzX+ggACgkQ+gerLs4ltQ7WQwCeNu4lF+WysIjSYM86EjMhoPFH<br>
9ZsAnRB7T4Pz+bIVeVYxHbvRYaqN6iE7<br>
=U5bo<br>
-----END PGP SIGNATURE-----<br>
<br>
_______________________________________________<br>
Zope-Dev maillist  -  <a href="mailto:Zope-Dev@zope.org">Zope-Dev@zope.org</a><br>
<a href="https://mail.zope.org/mailman/listinfo/zope-dev" target="_blank">https://mail.zope.org/mailman/listinfo/zope-dev</a><br>
**  No cross posts or HTML encoding!  **<br>
(Related lists -<br>
 <a href="https://mail.zope.org/mailman/listinfo/zope-announce" target="_blank">https://mail.zope.org/mailman/listinfo/zope-announce</a><br>
 <a href="https://mail.zope.org/mailman/listinfo/zope" target="_blank">https://mail.zope.org/mailman/listinfo/zope</a> )<br>
</blockquote></div><br></div></div>