Python – In Python, is there a way to detect the use of incorrect variable names? Something like VB’s “Option Explicit”?

In Python, is there a way to detect the use of incorrect variable names? Something like VB’s “Option Explicit”?… here is a solution to the problem.

In Python, is there a way to detect the use of incorrect variable names? Something like VB’s “Option Explicit”?

Most of my development work is done in Java and C++, but recently I had to write various scripts and choose Python. I run python from the command line of the script; Not in interactive mode. I wonder if it’s

I

love a lot of the advantages of this language, but one thing that keeps slowing down my productivity is that if I use undefined variables, I don’t get pre-warning.

For example, somewhere in the code, I forgot to prefix the variable’s declaration module, or I made a little typo and I first learned it was when the program crashed.

Is there a way for the python interpreter to give a prewarning when I access a variable that I haven’t accessed yet, or a variable set elsewhere in the program? I realize it’s a bit against the philosophy of language, but I can’t be the only one who makes these silly mistakes and can’t spot them early.

Solution

Pydev integrates well with Pylint, see here — and pylint is a more powerful checker than pyflakes (except for minor misspelling of variables). , it also catches style violations and more — it’s highly customizable regardless of your specific purpose!) .

Related Problems and Solutions