[Cython] Possible bug when using cython -Wextra

Stefan Behnel stefan_ml at behnel.de
Thu Feb 7 19:05:55 CET 2013


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.

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.

Stefan



More information about the cython-devel mailing list