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


Groups > comp.lang.python > #20187

How can I catch misnamed variables?

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!xmission!newsswitch.lcs.mit.edu!bloom-beacon.mit.edu!panix!gordon
From John Gordon <gordon@panix.com>
Newsgroups comp.lang.python
Subject How can I catch misnamed variables?
Date Fri, 10 Feb 2012 21:06:58 +0000 (UTC)
Organization PANIX Public Access Internet and UNIX, NYC
Lines 27
Message-ID <jh40ti$t3i$1@reader1.panix.com> (permalink)
NNTP-Posting-Host panix2.panix.com
X-Trace reader1.panix.com 1328908018 29810 166.84.1.2 (10 Feb 2012 21:06:58 GMT)
X-Complaints-To abuse@panix.com
NNTP-Posting-Date Fri, 10 Feb 2012 21:06:58 +0000 (UTC)
User-Agent nn/6.7.3
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20187

Show key headers only | 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