OK, thanks for the info. It&#39;s interesting, though, that I can code something like this in Cython and it works:<div><br></div><div><br></div><div><div>cdef class Foo:</div><div>    foos = {}</div><div><br></div><div>    def __cinit__(self, name):</div>
<div>        Foo.foos[name] = self</div><div><br></div></div><div><br></div><div><div><div>&gt;&gt;&gt; a = Foo(&#39;Larry&#39;)</div><div>&gt;&gt;&gt; b = Foo(&#39;Bob&#39;)</div><div>&gt;&gt;&gt; a.foos</div><div>{&#39;Bob&#39;: &lt;foo.Foo object at 0x01C5F490&gt;, &#39;Larry&#39;: &lt;foo.Foo object at 0x01C5F488&gt;}</div>
<div>&gt;&gt;&gt; b.foos</div><div>{&#39;Bob&#39;: &lt;foo.Foo object at 0x01C5F490&gt;, &#39;Larry&#39;: &lt;foo.Foo object at 0x01C5F488&gt;}</div></div></div><div><br></div><div><br></div><div>Perhaps I could use a hack workaround with the aforementioned count variable by storing it inside a class level list object.</div>
<div><br></div><div><br><div class="gmail_quote">2009/6/2 Chris Colbert <span dir="ltr">&lt;<a href="mailto:sccolbert@gmail.com">sccolbert@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
This is correct, forget what I said. I should have tried it out before I said anything. My apologies. <br><div><div></div><div class="h5"><br><br><br><div class="gmail_quote">On Tue, Jun 2, 2009 at 12:44 PM, Lisandro Dalcin <span dir="ltr">&lt;<a href="mailto:dalcinl@gmail.com" target="_blank">dalcinl@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left:1px solid rgb(204, 204, 204);margin:0pt 0pt 0pt 0.8ex;padding-left:1ex">No, that will not work. AFAIK, Class attributes are not currently<br>
supported for cdef classes.<br>
<br>
Juha, you will have to code like this:<br>
<br>
<br>
# foo.pyx<br>
<br>
cdef int Foo_count = 0<br>
<br>
cdef class Foo:<br>
<br>
    def __cinit__(self):<br>
        global Foo_count<br>
        Foo_count += 1<br>
<div><div></div><div><br>
<br>
<br>
<br>
On Tue, Jun 2, 2009 at 1:36 PM, Chris Colbert &lt;<a href="mailto:sccolbert@gmail.com" target="_blank">sccolbert@gmail.com</a>&gt; wrote:<br>
&gt; you have to declare the attribute as public.<br>
&gt;<br>
&gt; <a href="http://docs.cython.org/docs/extension_types.html" target="_blank">http://docs.cython.org/docs/extension_types.html</a><br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt; Chris<br>
&gt;<br>
&gt; On Tue, Jun 2, 2009 at 11:17 AM, Juha Salo &lt;<a href="http://jusa.sj" target="_blank">jusa.sj</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Unfortunately that didn&#39;t seem to work. I got the following error after<br>
&gt;&gt; the change:<br>
&gt;&gt; &gt;&gt;&gt; a = Foo()<br>
&gt;&gt; Traceback (most recent call last):<br>
&gt;&gt;   File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;<br>
&gt;&gt;   File &quot;foo.pyx&quot;, line 7, in foo.Foo.__cinit__ (foo.c:388)<br>
&gt;&gt;     self.count += 1<br>
&gt;&gt; AttributeError: &#39;foo.Foo&#39; object attribute &#39;count&#39; is read-only<br>
&gt;&gt;<br>
&gt;&gt; To clarify, I want the value of the count variable to remain the same<br>
&gt;&gt; between all instances. So if I create 3 Foo objects, each object should show<br>
&gt;&gt; 3 as the value in the count variable.<br>
&gt;&gt;<br>
&gt;&gt; 2009/6/2 Cristi Constantin &lt;<a href="mailto:darkgl0w@yahoo.com" target="_blank">darkgl0w@yahoo.com</a>&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Good day.<br>
&gt;&gt;&gt; You should try self.count += 1 instead of Foo.count += 1.<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Cython-dev mailing list<br>
&gt;&gt; <a href="mailto:Cython-dev@codespeak.net" target="_blank">Cython-dev@codespeak.net</a><br>
&gt;&gt; <a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Cython-dev mailing list<br>
&gt; <a href="mailto:Cython-dev@codespeak.net" target="_blank">Cython-dev@codespeak.net</a><br>
&gt; <a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br>
&gt;<br>
&gt;<br>
<br>
<br>
<br>
</div></div><font color="#888888">--<br>
Lisandro Dalcín<br>
---------------<br>
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)<br>
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)<br>
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)<br>
PTLC - Güemes 3450, (3000) Santa Fe, Argentina<br>
Tel/Fax: +54-(0)342-451.1594<br>
</font><div><div></div><div>_______________________________________________<br>
Cython-dev mailing list<br>
<a href="mailto:Cython-dev@codespeak.net" target="_blank">Cython-dev@codespeak.net</a><br>
<a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br>
</div></div></blockquote></div><br>
</div></div><br>_______________________________________________<br>
Cython-dev mailing list<br>
<a href="mailto:Cython-dev@codespeak.net">Cython-dev@codespeak.net</a><br>
<a href="http://codespeak.net/mailman/listinfo/cython-dev" target="_blank">http://codespeak.net/mailman/listinfo/cython-dev</a><br>
<br></blockquote></div><br></div>