pylint - why does Python lint want me to use different local variable name, than a global, for the same purpose -


Looking at the Python code such as

  def func (): for category i ( 10): Near pass for the border (10): pass  

pylint complaint

  redefining the name 'I' from outer area < / Code> 

What is the insignificant way to write above? Use a different variable locally, j ?

Say, but why, when the meaning of the variable is exactly the same in both cases (for the i index) assume that I will assign all the local index to j And later I think I want to use j as the second index in the global scope. Have to change again?

I can not disable Lint Alerts, I do not want them, I want to write Pithanik, and still I want to use the same name as the same name, in the simple case above. Is this not possible?

linter warns because i remains after the loop, if it Run at least once. This means that if you are using it without restarting it, then it will still be the value during the last iteration of the loop.

The way you use it is ok because i will always be restarted.

A useful practice can be the name of all the values ​​in the outer scope of the ALL_CAPS . No mistake can be made in this way.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -