does lack of type declarations make Python unsafe?
Peter Hansen
peter at engcorp.com
Sun Jun 15 18:04:21 EDT 2003
beliavsky at aol.com wrote:
>
> In Python, you don't declare the type of a variable, so AFAIK there is
> no way for the interpreter to check that you are calling functions
> with variables of the correct type.
This whole discussion has taken place, repeatedly, in the past,
so if you would like to check the archives you'll find a few
dozen versions of the question and the lengthy threads that ensued.
> Calling functions with invalid arguments is one of the commonest
> programming errors
Debatable. Not true in my experience.
> I worry that
> Python's convenience in writing small programs comes at the cost of
> making bug-free large programs more difficult to write.
Actually, Python seems to make writing both small and large programs
easier, and especially (and more importantly) makes *reading* them
much easier, which eases maintenance.
> I have only been programming in Python for a few weeks -- am I right
> to worry?
> Are there techniques to ensure that functions are called with
> appropriate arguments?
I'm on the side that says unit testing is a better way of catching
such problems, and Python makes unit testing much easier than many
other languages, so it's a match made in heaven (or is that Holland? ;-).
-Peter
More information about the Python-list
mailing list