Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20187

How can I catch misnamed variables?

From John Gordon <gordon@panix.com>
Newsgroups comp.lang.python
Subject How can I catch misnamed variables?
Date 2012-02-10 21:06 +0000
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <jh40ti$t3i$1@reader1.panix.com> (permalink)

Show all headers | View raw


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.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

How can I catch misnamed variables? John Gordon <gordon@panix.com> - 2012-02-10 21:06 +0000
  Re: How can I catch misnamed variables? Arnaud Delobelle <arnodel@gmail.com> - 2012-02-10 21:17 +0000
  Re: How can I catch misnamed variables? Kev Dwyer <kevin.p.dwyer@gmail.com> - 2012-02-10 21:22 +0000
  Re: How can I catch misnamed variables? Ben Finney <ben+python@benfinney.id.au> - 2012-02-11 08:26 +1100
    OT (waaaayyyyyyyyy off-topic) [was Re: How can I catch misnamed variables?] Ethan Furman <ethan@stoneleaf.us> - 2012-02-10 13:56 -0800
      Re: OT (waaaayyyyyyyyy off-topic) Ben Finney <ben+python@benfinney.id.au> - 2012-02-11 09:45 +1100
  Re: How can I catch misnamed variables? Christian Heimes <lists@cheimes.de> - 2012-02-11 00:21 +0100

csiph-web