annoying behavior

Michael Hoffman m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Tue Sep 28 18:58:27 EDT 2004


Elbert Lev wrote:

> I think, it would be good, if some sort of warning is given during
> import, but not during instantiating the instance of the class. At
> least in a "debug" mode. What really did happen: the bug was reported
> after the scrip was running for 30 minutes. PyCheck finds it
> immediatelly. Why not to do the same kind of check in the interpreter?

Can you post the results of your PyChecker run and the exact input to it?

I just did a test myself:

"""
$ cat test1.py
class X(object):
     def __init__(self):
         self.f()
         self.r = True

     def f(self):
         print self.r

def main():
     x = X()

$ pychecker test1.py
Processing test1...

Warnings...

test1.py:10: Local variable (x) not used
"""

I think that what you want the Python compiler to do is harder than you 
think it is, and not all cases will be caught unless you actually run 
the program.

I've forgotten to assign attributes and variables before using them in 
the past--it's just something you have to learn not to do.
-- 
Michael Hoffman



More information about the Python-list mailing list