By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,546 Members | 1,382 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,546 IT Pros & Developers. It's quick & easy.

Identifying apparently unused globals

P: n/a

At work we have a fairly large application (about 20 packages, 300+ modules)
that looks like we might be heading into a bit of a plateau stage. Now
seems like a good time to identify and delete old, unused code that's flown
under the radar screen for awhile simply because nobody was looking for it.
Trouble is, most of that unused code consists of module-level classes,
functions and variables, so it's hard to distinguish mechanically from code
that *is* used. Is there a tool out there that will slurp in a number of
packages, identify all the global names then remove those that it determines
are referenced? (Yes, I know it's impossible to do this in general. We
have one very restricted exec statement and no eval() calls, so I'm not too
worried about that sort of obfuscation.)

Thx,

Skip
Jul 11 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
sk**@pobox.com wrote:
At work we have a fairly large application (about 20 packages, 300+ modules)
that looks like we might be heading into a bit of a plateau stage. Now
seems like a good time to identify and delete old, unused code that's flown
under the radar screen for awhile simply because nobody was looking for it.
Trouble is, most of that unused code consists of module-level classes,
functions and variables, so it's hard to distinguish mechanically from code
that *is* used. Is there a tool out there that will slurp in a number of
packages, identify all the global names then remove those that it determines
are referenced? (Yes, I know it's impossible to do this in general. We
have one very restricted exec statement and no eval() calls, so I'm not too
worried about that sort of obfuscation.)

Thx,

Skip
I haven't used it myself, but pychecker
(http://pychecker.sourceforge.net/) is supposed to be able to perform
such stunts. From the page: "Types of problems that can be found
include: Unused globals and locals (module or variable)"

HTH,
~Simon

Jul 11 '06 #2

P: n/a

SimonI haven't used it myself, but pychecker
Simon(http://pychecker.sourceforge.net/) is supposed to be able to
Simonperform such stunts. From the page: "Types of problems that can
Simonbe found include: Unused globals and locals (module or variable)"

Thanks. I've used both pylint and pychecker. I'm not aware that either one
can do what I want. Here's a trivial example:

Module a.py:

RED = "red"
BLUE = "blue"

Module b.py:

import a
print a.RED

Considering modules a and b as a whole program, a.BLUE is unused anywhere in
the program.

Skip
Jul 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.