does lack of type declarations make Python unsafe?

Peter Hansen peter at engcorp.com
Mon Jun 16 16:19:47 CEST 2003


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




More information about the Python-list mailing list