does lack of type declarations make Python unsafe?

Dang Griffith dmgriffith_not_ at tasc.com
Tue Jun 17 08:27:42 EDT 2003


Peter Hansen wrote:

> Gary Duncan wrote:
> > 
> > Alex Martelli wrote:
> > 
> > >>>Calling functions with invalid arguments is one of the commonest
> > >>>programming errors
> > >>
> > >>Debatable.  Not true in my experience.
> 
> (To clarify, in the face of trimmed attributions: I, not Alex, wrote 
> the last sentence above.)
> 
> > I suspect this assertion relates to juxtaposing args, not so
> > much the values thereof. Obviously passing bad values to a function
> > is a crime we have all committed - at least it's one I admit to ;)
> 
> If we consider that bugs come from either bad data or bad logic, and
> that bad logic will very likely or inevitably lead to bad data, and
> that all data eventually is used as an "argument" in some fashion,
> I'll agree that calling functions with invalid arguments is quite
> common. :-)
> 
> To take up Alex' point: passing in the wrong type is probably much
> less common than, say, using the wrong value, or mixing up the order
> of arguments (and many functions take a bunch of arguments of the
> same type, so type-checking doesn't help there!).
> 
> -Peter
   A common example--most OO GUI libraries include a type of "Point". 
I've yet to see a Point class that is composed of a pair of ordinate and
abscissa type objects.  Talk about an easy way to get turned around
without the compiler even hinting at a problem.
      --dang




More information about the Python-list mailing list