I talked with the CIS department chairman and one of the faculty about the 
possibility of teaching Python at our community college, and they weren't 
interested.  (Oh No, not another language ... )  Also, the lack of declarations 
was a show-stopper.  

I encountered this same objection from one of the faculty at U of A, where I 
just gave a lecture.  It doesn't seem to help when I say: In four years of 
using Python, I can remember only one time when I had a subtle error from 
mistyping a variable name that took an hour to track down.  I'll gladly trade 
that hour for the dozens I've saved not having to read and write all these 
declarations.

I've added this to my QnA page at 
http://ece.arizona.edu/~edatools/ece175/Lecture/QnA.txt

'''
Q2: Without variables declarations, isn't there a problem with mistyped
variable names leading to subtle errors?

A2: It can happen, but the subtle errors are rather rare.  Usually you will
get an immediate and clear message like:

   Traceback (most recent call last):
    - - -
   NameError: name 'z' is not defined

where 'z' is the name you intended to type.  The subtle error can occur if z
is already defined, and you intended to re-define it.

If you worry about errors like this, you can scan your program with a
utility like pychecker, and it will detect any variables that are defined
but never used.
'''

Still, I wonder if there isn't a better way to handle this objection to Python. 
 I'm thinking of a configuration option in IDLE, something that will either:

1) Run a subset of pychecker tests every time you hit the Run button, or
2) Insist on declarations in a comment at the start of every function (just the 
names, not data types).  Any name that isn't already declared gets immediately 
painted red.

I would use #1 if it was no time penalty.  #2 seems like "training wheels" to 
me, but I would expect some folks who are religious about declarations might at 
least find it re-assuring.

-- Dave


_______________________________________________
Edu-sig mailing list
Edu-sig@python.org
http://mail.python.org/mailman/listinfo/edu-sig

Reply via email to