On 14 February 2013 05:08, Robert Bradshaw <rober...@gmail.com> wrote: > On Thu, Feb 7, 2013 at 10:05 AM, Stefan Behnel <stefan...@behnel.de> wrote: >> Samuele Kaplun, 07.02.2013 13:00: >>> In data giovedì 7 febbraio 2013 12:11:47, Stefan Behnel ha scritto: >>>>> [...] >>>>> >>>>> def test(): >>>>> cdef int i >>>>> >>>>> for i from 0 <= i < 10: >>>>> print "foo" >>>>> >>>>> [...] >>>> >>>> Yes, it actually is an unused variable in your code. There is no reference >>>> to it, only assignments. >>> >>> mmh. But is it used albeit indirectly. Then what pattern would you suggest >>> in >>> this case (i.e. to repeat a certain body a given number of times), in order >>> to >>> avoid such warning? >> >> The normal thing to do in Python would be to use an underscore (i.e. "_") >> as variable name. I don't think we currently special case that pattern, >> though. Maybe we should. > > I agree. Done. > >> Or maybe we should just drop the "unused variable" warning for loop >> variables as they actually do something and serve a purpose, even if they >> are never referenced. > > +1 to this too. (Not yet done.)
Yeah, I think that's the sanest thing. I already implemented this in Numba which bases its control flow on Cython's (because it's awesome, thanks to Vitja :)). It simply adds a flag to NameAssignment which is set for the ForNode's target variable. > - Robert > _______________________________________________ > cython-devel mailing list > cython-devel@python.org > http://mail.python.org/mailman/listinfo/cython-devel _______________________________________________ cython-devel mailing list cython-devel@python.org http://mail.python.org/mailman/listinfo/cython-devel