[Q] Are Exceptions used that much in practice?

Tim Hammerquist tim at degree.ath.cx
Wed Dec 13 07:24:29 CET 2000

Jerome Mrozak <goose at enteract.com> wrote:
> I believe I've been misunderstood.  The problem is not "can I write code
> without handling exceptions" but rather "are exceptions used
> voluntarily, rather than by compulsion".

I thought the overwhelming response was "YES!", but maybe I'm just

> The long-range goal of my question is to determine for my satisfaction
> whether it is worth while for me to spend my limited time pursuing
> Python as a compliment to (whatever other skills I might have) or to go
> with the apparently much greater flow and use those resources on Perl. 
> The 'exception' thing could be a determiner, esp. with nothing similar
> in Perl, but only if I can use it in a *positive* way instead of just to
> test a return value.  Heck, Perl has 'die' for that kind of testing.

Perl has signal-trapping on top of the 'eval(...);if($@){...}' struct, on top
of being able to disguise the later as the much more recognisable:

: try {...}
: catch {...}

along with the ability to pass custom objects, in addition to the normal
strings, via the $@ variable.  And although Python's implementation is
much more graceful, Perl can by all means accomplish the same task.
Both languages are extremely powerful and flexible.  You won't be
limiting yourself with either language in terms of what you can
accomplish.  As far as I can tell, the choice between Python and Perl is
more a matter of what you're comfortable with and which fits your
personality.  I must have multiple personalities, because I won't
choose.  =)

And besides, if you ask "What's better: Python or Perl?" in a python NG,
what answer do you expect?

Try both.  Perl is a significantly different style from most people's
experience, unless that experience consisted highly of Unix shell
programming.  Python may suit your current skills (whatever, if any,
they might be) better.  Don't let us decide for you.

And yes, exceptions are used voluntarily and frequently by thousands of
programmers daily because it makes their jobs easier and they can be

And if THAT doesn't answer your question...  =)

-Tim Hammerquist <timmy at cpan.org>

Not all who wander are lost.
	-- J.R.R. Tolkien

More information about the Python-list mailing list