[Python-projects] Incorrect unused variable warning

skip at pobox.com skip at pobox.com
Sat Nov 8 03:35:34 CET 2008


pylinting this code:

    def f():
        for a in range(10):
            pass

        y = set([a**2 for a in range(10)])

yields this output:

    pylintex.py:5: [W, f] Using possibly undefined loop variable 'a'
    pylintex.py:5: [W, f] Unused variable 'y'

If you take away the for loop it doesn't complain about a.

-- 
Skip Montanaro - skip at pobox.com - http://www.webfast.com/~skip/


More information about the Python-Projects mailing list