How can I catch misnamed variables?

J

John Gordon

Recently I was been bitten by some stupid errors in my code, and I'm
wondering if there's a simple way to catch them.

One error was of the form:

my_object.some_function()

... when I hadn't declared an object named "my_object".

The other error was similar:

x = my_module.CONSTANT

... when I hadn't imported my_module.

Of course both of these errors were deep inside a long-running function
call, so it took a while for them to crop up.

Is there an automated way to catch errors like these? I'm using the
compileall module to build my program and it does catch some errors
such as incorrect indentation, but not errors like the above.
 
A

Arnaud Delobelle

Recently I was been bitten by some stupid errors in my code, and I'm
wondering if there's a simple way to catch them.

One error was of the form:

 my_object.some_function()

.. when I hadn't declared an object named "my_object".

The other error was similar:

 x = my_module.CONSTANT

.. when I hadn't imported my_module.

Of course both of these errors were deep inside a long-running function
call, so it took a while for them to crop up.

Is there an automated way to catch errors like these?  I'm using the
compileall module to build my program and it does catch some errors
such as incorrect indentation, but not errors like the above.

There's pychecker and pylint
 
K

Kev Dwyer

John said:
Recently I was been bitten by some stupid errors in my code, and I'm
wondering if there's a simple way to catch them.
<snip>


Pyflakes is another static checker that can catch these sorts of errors.

Cheers,

Kev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top