Why does Pylint object to single-character variable names?

后端 未结 5 1742
我寻月下人不归
我寻月下人不归 2021-01-30 12:08

I\'m still getting used to Python conventions and using Pylint to make my code more Pythonic, but I\'m puzzled by the fact that Pylint doesn\'t like single character variable na

5条回答
  •  失恋的感觉
    2021-01-30 12:36

    A little more detail on what gurney alex noted: you can tell Pylint to make exceptions for variable names which (you pinky swear) are perfectly clear even though less than three characters. Find in or add to your pylintrc file, under the [FORMAT] header:

    # Good variable names which should always be accepted, separated by a comma
    good-names=i,j,k,ex,Run,_,pk,x,y
    

    Here pk (for the primary key), x, and y are variable names I've added.

提交回复
热议问题