[Python-Dev] PEP 8: exception style

Terry Reedy tjreedy at udel.edu
Sat Aug 6 22:28:56 CEST 2005


"Guido van Rossum" <gvanrossum at gmail.com> wrote in message 
news:ca471dc205080610104fb870ac at mail.gmail.com...
> On 8/6/05, A.M. Kuchling <amk at amk.ca> wrote:
>> PEP 8 doesn't express any preference between the
>> two forms of raise statements:
>> raise ValueError, 'blah'
>> raise ValueError("blah")
>>
>> I like the second form better, because if the exception arguments are
>> long or include string formatting, you don't need to use line
>> continuation characters because of the containing parens.  Grepping
>> through the library code, the first form is in the majority, used
>> roughly 60% of the time.
>>
>> Should PEP 8 take a position on this?  If yes, which one?
>
> Definitely ValueError('blah'). The other form will go away in Python
> 3000. Please update the PEP.

Great.  PEP 3000 could also be updated to add the line

The raise Error,'blah' syntax: use raise Error('blah') instead [14]

in the To be removed section after the line on string exceptions  and [14] 
<Guido's post> under references.

Terry J. Reedy





More information about the Python-Dev mailing list