tim.one at comcast.net
Mon Aug 19 18:24:42 CEST 2002
> Before I add to the current high volume on python-dev, does anyone know
> why the exception mechanism uses class objects rather than class
> instances. In other words, why don't we do
> raise Exception()
You can if you want to (try it!). I expect some people don't just because
it's more typing, while others don't because instantiating an instance of a
class is more expensive than merely using the (already full constructed)
class object itself.
Note that the more common form
raise ValueError, "man, this sucks! don't do that"
is wholly equivalent to
raise ValueError("man, this sucks! don't do that")
The former style is a leftover from the days when only strings could be
More information about the Python-list