That solved it. Thanks! 2009/5/18 Lisandro Dalcin <[email protected]>
> As in normal Python code, use 'global', if not, Cython will treat > 'foovar' as a local variable: > > cpdef set_foo(float v=0.001): > global foobar > foovar = v > > > > > On Mon, May 18, 2009 at 10:58 AM, Juha Salo <[email protected]> wrote: > > Hi, > > I ran into a rather basic problem where I can't seem to change the value > of > > a module-level Cython variable through a cpdef'd Cython function. I have > the > > following: > > #foo.pyx > > cdef float foovar = 0.001 > > cpdef float get_foo(): > > return foovar > > cpdef set_foo(float v=0.001): > > foovar = v > > > > > > When I call get_foo() at the Python interpreter I get the value 0.001, > but > > trying to change foovar's value with set_foo() has no effect. I also > tried > > to cpdef foovar but that didn't help. I could probably (?) define foovar > as > > a regular Python variable, but I'd rather have it as a Cython variable > for > > speed. Is there anything special that needs to be done to get this to > work? > > Thanks, > > J.S. > > _______________________________________________ > > Cython-dev mailing list > > [email protected] > > http://codespeak.net/mailman/listinfo/cython-dev > > > > > > > > -- > Lisandro Dalcín > --------------- > Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC) > Instituto de Desarrollo Tecnológico para la Industria Química (INTEC) > Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET) > PTLC - Güemes 3450, (3000) Santa Fe, Argentina > Tel/Fax: +54-(0)342-451.1594 > _______________________________________________ > Cython-dev mailing list > [email protected] > http://codespeak.net/mailman/listinfo/cython-dev >
_______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
