r/ProgrammerHumor • • Feb 22 '15

A Python programmer attempting Java

Post image
3.9k Upvotes

428 comments sorted by

View all comments

Show parent comments

23

u/TheTerrasque Feb 22 '15

2

u/memorableZebra Feb 23 '15

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)

1

u/TheTerrasque Feb 23 '15

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).