[Python-ideas] Definition Symmetry

Terry Reedy tjreedy at udel.edu
Fri Feb 1 02:07:27 CET 2013


On 1/31/2013 4:06 PM, Barry Warsaw wrote:
> On Jan 31, 2013, at 11:33 PM, Andrew Grigorev wrote:
>
>> Other strange thing is that the `raise` statement doesn't require to
>> instantiate an Exception object, allowing to pass an Exception class to it.
>>
>> raise NotImplementedError
>> raise NotImplementedError()
>>
>> Is there any difference between this two lines of code?

Questions like this below on python-list, not here.

> The main difference (I *think* this is still true) is that in the first
> example, if the exception is caught in C it can avoid instantiation.

The the second form allows addition of a message, which is usually a 
good idea.

-- 
Terry Jan Reedy




More information about the Python-ideas mailing list