[Python-Dev] PEP-317
Tim Peters
tim.one@comcast.net
Mon, 09 Jun 2003 11:28:12 -0400
[Terence Way]
> There is a rather pleasing symmetry between
> raise SomeClass, arg
> and
> assert expr, arg
>
> Is this intentional? If so, should the assert form be deprecated as
> well?
The symmetry is purely syntactic, and is misleading: assert is a control
structure, and doesn't evaluate "arg" unless the runtime value of expr is
false. For example,
>>> assert True, 1/0
>>> assert False, 1/0
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ZeroDivisionError: integer division or modulo by zero
>>>
raise always evaluates its arg.