Perl is worse!

Martijn Faassen m.faassen at vet.uu.nl
Sat Jul 29 11:23:42 EDT 2000


gbp <gpepice1 at nycap.rr.com> wrote:
>>
>> Hmm. You seem to expect that strings and other
>> things will be automatically coerced to integers whenever a function
>> expects an integer. I think that's pretty scary; when I pass in the wrong
>> thing to a function I *want* it to complain, as it's very likely I did it
>> by accident. I don't want things to work by accident. Perhaps you're
>> missing that this 'problem' is also a 'feature'; you get less 'weird'
>> bugs due to the fact that your program keeps running long after your
>> data got coerce-mangled to death. Python would tend to throw exceptions
>> as soon as it went wrong.

> I think it depends what you are doing with your program.  I use Perl (and now
> Python) to parse text files before putting the info in or sending it out of a
> databse.  This is by no means bug free software (deadlines just don't permit enough
> testing).  If someone sticks a letter in my input file where a number should go I
> would rather my script deal with it than crash.
> After all its not _my_ fault theres
> a letter there.  However, managment will blame me for a 'bug' if the
> program throws
> an exception when someone else runs it.

Right, but even in that case I'd seen handling of such things explicit
in the code, instead of just hoping nothing nasty will happen. You can
catch this type of thing with try..except and just script the broken
line or record or whatever your input may be. The alternative can
be pretty devastating; imagine you have this file with a number in 
each row, and your script multiplies them all. If the system just treats
a string (that doesn't contain an integer) as a zero, the answer will
suddenly be zero.

Regards,

Martijn 
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list