Yep, i red that later. But what about the &quot;no attribute&quot; thing that pop-ups when i try to call the methods? do u have any idea?<br><br>Thank u for the quick response,<br>Marco<br><br><div><span class="gmail_quote">2008/4/21, William Stein &lt;<a href="mailto:wstein@gmail.com">wstein@gmail.com</a>&gt;:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Mon, Apr 21, 2008 at 3:27 PM, Marco Zanger &lt;<a href="mailto:marcozanger@gmail.com">marcozanger@gmail.com</a>&gt; wrote:<br> &gt; Hi, I&#39;ve been reading the WrappingC++ code with pyrex/Cython. But I&#39;m still<br>
 &gt; unable to compile it; even the attached example.<br> &gt;<br> &gt; when I run&nbsp;&nbsp;&quot;pyrexc rectangle.pyx &quot;<br> &gt; I get:<br> &gt;<br> &gt; .../rectangle.pyx:29:27: Syntax error in C variable declaration<br> &gt;<br>
 &gt; Which refers to<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; def __add__(Rectangle left, Rectangle right):<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cdef c_Rectangle c = left.thisptr.add(right.thisptr[0])<br> <br> <br>I think Pyrex doesn&#39;t allow declaring and setting a variable, i.e.,<br>
 <br>&nbsp;&nbsp;cdef int i = 10<br> <br> is not valid Pyrex.&nbsp;&nbsp;You have to write:<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;cdef int i<br>&nbsp;&nbsp;&nbsp;&nbsp;i = 10<br> <br> In contrast, Cython allows<br> <br>&nbsp;&nbsp;&nbsp;&nbsp;cdef int i = 10<br> <br> since Robert Bradshaw was working on Cython one day and thought that<br>
 would be a nice feature to have...<br> <br>&nbsp;&nbsp;-- William<br> <br><br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cdef Rectangle sum = Rectangle(c.x0, c.y0, c.x1, c.y1)<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return sum<br> &gt;<br> &gt; And in my own code i get the following<br>
 &gt;<br> &gt; GOptimization.pyx:91:32: Object of type &#39;cGCoptimization&#39; has no attribute<br> &gt; &#39;expansionIter&#39;<br> &gt;<br> &gt; And the code which refers is<br> &gt;<br> &gt; cdef extern from &quot;GCoptimization.h&quot;:<br>
 &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;ctypedef int PixelType<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ctypedef struct cGCoptimization &quot;GCoptimization&quot;:<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EnergyType expansionIter &quot;expansion&quot;(int max_num_iterations)<br> &gt;<br>
 &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cGCoptimization *newGCoptimization &quot;new GCoptimization&quot; (PixelType<br> &gt; num_pixels,int num_labels,int dataSetup, int smoothSetup)<br> &gt;<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; void delGCOptimization &quot;delete&quot; (cGCoptimization *optimization)<br>
 &gt;<br> &gt; cdef class GCoptimization:<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cdef cGCoptimization *optimization<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; def __new__(self, num_pixels, num_labels, dataSetup, smoothSetup):<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.optimization = newGCoptimization(num_pixels, num_labels,<br>
 &gt; dataSetup, smoothSetup)<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; def __dealloc__(self):<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delGCOptimization(self.optimization)<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp; def expansionIter(self,max_num_iterations):<br> &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return self.optimization.expansionIter(max_num_iterations)<br>
 &gt;<br> &gt; If u have any idea to give I would appreciate it very much, I&#39;m kind of lost<br> &gt; in here.<br> &gt;<br> &gt; Thank you, again,<br> &gt; Warmest Regards,<br> &gt; Marco<br> <br>&gt; _______________________________________________<br>
 &gt;&nbsp;&nbsp;Pyrex mailing list<br> &gt;&nbsp;&nbsp;<a href="mailto:Pyrex@lists.copyleft.no">Pyrex@lists.copyleft.no</a><br> &gt;&nbsp;&nbsp;<a href="http://lists.copyleft.no/mailman/listinfo/pyrex">http://lists.copyleft.no/mailman/listinfo/pyrex</a><br>
 &gt;<br> &gt;<br> <br><br> <br> <br> --<br> William Stein<br> Associate Professor of Mathematics<br> University of Washington<br> <a href="http://wstein.org">http://wstein.org</a><br> </blockquote></div><br>