Roy Smith wrote: >I think you've hit the nail on the head. In awk (and perl, and most >shells, and IIRC, FORTRAN), using an undefined variable silently gets >you a default value (empty string or zero). This tends to propagate >errors and make them very difficult to track down.
You may recall correctly, but Fortran compilers have improved. The following Fortran 90 program integer, parameter :: n = 1 real :: x,y=2.0,z(n) print*,"dog" print*,x z(n+1) = 1.0 print*,z end has 3 errors, all detected at compile time by the Lahey/Fujitsu Fortran 95 compiler, with the proper options: 2004-I: "xundef.f", line 2: 'y' is set but never used. 2005-W: "xundef.f", line 4: 'x' is used but never set. 2153-W: "xundef.f", line 5, column 1: Subscript out of range. At run time, the output is dog The variable (x) has an undefined value. Error occurs at or near line 4 of _MAIN__ Running Python 2.4 on the Python analog, n = 1 y = 2.0 z = range(n) print "dog" print x z[n] = 1.0 print z one error is caught: dog Traceback (most recent call last): File "xundef.py", line 5, in ? print x NameError: name 'x' is not defined You will see the out-of-bounds error for z only after fixing the undefined-x error. No warning is ever given about y, which is set but never used. In practice, 'print "dog"' could be some operation taking hours. Can PyChecker find all the problems in a single run, without executing 'print "dog"'? If so, it would be great if it were integrated with the CPython interpreter. One reason interpreted languages like Python are recommended to beginners is to avoid the edit/compile/debug cycle. But I think it is faster and less frustrating to have many errors caught in one shot. -- http://mail.python.org/mailman/listinfo/python-list