type checking

Stephen Horne $$$$$$$$$$$$$$$$$ at $$$$$$$$$$$$$$$$$$$$.co.uk
Sun Oct 12 01:21:51 EDT 2003


On Sun, 12 Oct 2003 15:56:19 +1300, sashan <mabus at operamail.com>
wrote:

>I'm a Python newbie. I have been using c++ for 5 years and before that I 
>  was programming in Pascal. The one thing that annoys me about python 
>is dynamic typing because I find myself making typographical errors of 
>the sort that would under C++ be picked up by the compiler at compiler 
>time.  With Python I have to wait for the error to appear at runtime in 
>order for me to correct it. I find this inefficient. Any advice about 
>how to get around this would be appreciated.

Personally, I find that I rarely make these errors in Python. Having
the right datatype is in any case no guarantee of having the right
value.

In Python, bugs are primarily avoided by writing clear code (so that
it is hard to make non-obvious errors) and detected by testing (which
is the only approach that checks whether the requirements are met).

There are also alternative self-consistency checking schemes such as
design-by-contract that may work well for you, though they do operate
at run time rather than compile time.

If you really do need static typing (as opposed to simply needing to
get used to the change), Python is simply the wrong choice of
language. Either Java, C# or Delphi may be a good option for you.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk




More information about the Python-list mailing list