[Python] Pylint wants a variable to be named as a constant [C0103]

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    Why does Pylint require a variable to have UPPER_CASE naming as though it is a constant?

    """Stack reproducible example."""

    some_list = ['foo', 'bar']
    for i in some_list:
    counter = 3
    while counter != 0:
    print("Value of 'counter': " + str(counter))
    counter -= 1


    This gives the linting error of:

    # C0103: Constant name "counter" doesn't conform to UPPER_CASE naming style (invalid-name)


    However unlike Avogadro's Constant, Pi, or the speed of sound in a vaccum, the value of counter changes which surely must render it a 'variable'?

    I have read the page regarding C0103 but I obviously don't understand something.

    Is a for-loop considered a single-use function thus altering convention such as in this question?

    Continue reading...

Compartilhe esta Página