Re: annoying behavior
Michael Hoffman <m.h.3.9.1.with out.dots.at.cam .ac.uk@example. com> wrote in message news:<cjcqao$ji 0$1@gemini.csx. cam.ac.uk>...[color=blue]
> Elbert Lev wrote:
>[color=green]
> > 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?[/color]
>
> 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.[/color]
Here it is:
Processing test...
C:\Python23\pyt hon.exe
C:\Python23\Lib \site-packages\pychec ker\checker.py
test.py
Caught exception importing module test:
File "C:\Python23\Li b\site-packages\pychec ker\checker.py" , line
576, in setupMainCode()
module = imp.load_module (self.moduleNam e, file, filename, smt)
File "test.py", line 16
f = foo("1234")
File "test.py", line 5, in __init__()
self.f()
File "test.py", line 9, in f()
if self.r:
AttributeError: foo instance has no attribute 'r'
Warnings...
test:1: NOT PROCESSED UNABLE TO IMPORT
[color=blue]
> 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.[/color]
Sure not all! I tell you more: in many cases after the program was
used for years, it contains errors. This does not stop people debuging
them :) Even if check does not finds all errors it will be very good.
Isn't this what Python is about - fast and fun programming, not
frustration. After all, if I want troubles, I always can use C or Java
:))
Michael Hoffman <m.h.3.9.1.with out.dots.at.cam .ac.uk@example. com> wrote in message news:<cjcqao$ji 0$1@gemini.csx. cam.ac.uk>...[color=blue]
> Elbert Lev wrote:
>[color=green]
> > 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?[/color]
>
> 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.[/color]
Here it is:
Processing test...
C:\Python23\pyt hon.exe
C:\Python23\Lib \site-packages\pychec ker\checker.py
test.py
Caught exception importing module test:
File "C:\Python23\Li b\site-packages\pychec ker\checker.py" , line
576, in setupMainCode()
module = imp.load_module (self.moduleNam e, file, filename, smt)
File "test.py", line 16
f = foo("1234")
File "test.py", line 5, in __init__()
self.f()
File "test.py", line 9, in f()
if self.r:
AttributeError: foo instance has no attribute 'r'
Warnings...
test:1: NOT PROCESSED UNABLE TO IMPORT
[color=blue]
> 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.[/color]
Sure not all! I tell you more: in many cases after the program was
used for years, it contains errors. This does not stop people debuging
them :) Even if check does not finds all errors it will be very good.
Isn't this what Python is about - fast and fun programming, not
frustration. After all, if I want troubles, I always can use C or Java
:))
Comment