questions about of writing python scripts
jeff at ccvcorp.com
Mon Dec 10 13:50:51 EST 2001
> Hi I have a question regarding writing python scripts..
> for large program written i python,, One thing i notice is it needs to
> run to the specifc piece of code i order to detect error. let's say
> the valaue is assigned to a wrong variables, I cannot know in advance,
> but c is floating and has not value and a got assgined to it. ... in
> other compiation lang, this type of error will be caught in
> compilaiton time, but I can't using python.. is ther any utility or
> way to catch this type of error way ahead?
PyChecker may catch some (or most) of this sort of error for you, but in
general, the way to catch this sort of error is to test your code. You
need to test the code anyhow--compilers can catch some errors, but not
logic/algorithm errors, so the fact that your code compiles does not make
it "right". (Although many people seem to think it does... a problem in
and of itself.) If you test your code even marginally, you're almost
guaranteed to find that sort of assignment error.
To many people it seems wrong to "wait until runtime" to find these
errors, but really, you'll be able to write, test, and correct a Python
program faster than you'd be able to get to the point of even *trying* to
compile a C++ program... Just remember that compile-time checks vs
run-time checks is a cultural issue; statically-typed languages have a
culture that strongly favors compile-time, while dynamic languages have a
culture favoring run-time.
More information about the Python-list