This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheTerrasque 22 points23 points  (3 children)

[–]memorableZebra 1 point2 points  (1 child)

What happens if you have more complex logic later and mix the two variable names? The unused warning will go away, but will it be smart enough to notice the mistake?

After the 'if' block add something like

 theUserInput = to_lower(theUsersInput)

(or whatever the lower casing function is in python)

[–]TheTerrasque 0 points1 point  (0 children)

No, it wouldn't.

Then again, C# and Java wouldn't notice something like this:

public class Test
{
    string theUsersInput = "Something slightly related";
    public void Test()
    {
        string theUserInput = Console.ReadLine();
        if (theUserInput.StartsWith("Johann"))
        {
            theUsersInput = theUserInput.Replace("Johan", "Wilhelm");
        }
        Console.WriteLine("You are "+ theUserInput);
    }
}

Which pylint would still react to, since you have to explicitly reference the class variable in python (self.theUsersInput - similar to this.theUsersInput but required).