Re: [Python-Dev] PEP 8: exception style

2005-08-07 Thread Michael Hudson
Guido van Rossum [EMAIL PROTECTED] writes:

 On 8/6/05, A.M. Kuchling [EMAIL PROTECTED] 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.

How do you then supply a traceback to the raise statement?

Cheers,
mwh

-- 
  please realize that the Common  Lisp community is more than 40
  years old.  collectively, the community has already been where
  every clueless newbie  will be going for the next three years.
  so relax, please. -- Erik Naggum, comp.lang.lisp
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-07 Thread Guido van Rossum
 How do you then supply a traceback to the raise statement?

raise ValueError, ValueError(blah), tb

Maybe in Py3K this could become

raise ValueError(bloop), tb

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-07 Thread Raymond Hettinger
  How do you then supply a traceback to the raise statement?
 
 raise ValueError, ValueError(blah), tb
 
 Maybe in Py3K this could become
 
 raise ValueError(bloop), tb

The instantiation and bindings need to be done in one step without
mixing two syntaxes.  Treat this case the same as everything else:

raise ValueError(blip, traceback=tb)



Raymond

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-07 Thread Guido van Rossum
  Maybe in Py3K this could become
 
  raise ValueError(bloop), tb
 
 The instantiation and bindings need to be done in one step without
 mixing two syntaxes.  Treat this case the same as everything else:
 
 raise ValueError(blip, traceback=tb)

That requires PEP 344. I have some vague feeling that the way we build
up the traceback by linking backwards, this may not necessarily work
right. I guess somebody has to try to implement PEP 344 in order to
find out.

(In fact, I think trying to implement PEP 344 would be an *excellent*
way to validate it.)

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-06 Thread Robert Brewer
A.M. Kuchling 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?

I like the second form better, because even intermediate Pythonistas
sometimes make a mistake between:

raise ValueError, A

and

raise (ValueError, A)

I'd like to see the first form removed in Python 3k, to help reduce the
ambiguity. But PEP 8 taking a stand on it would be a good start for now.


Robert Brewer
System Architect
Amor Ministries
[EMAIL PROTECTED]
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-06 Thread Guido van Rossum
On 8/6/05, A.M. Kuchling [EMAIL PROTECTED] 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.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-06 Thread Terry Reedy

Guido van Rossum [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 On 8/6/05, A.M. Kuchling [EMAIL PROTECTED] 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



___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] PEP 8: exception style

2005-08-06 Thread Brett Cannon
On 8/6/05, Guido van Rossum [EMAIL PROTECTED] wrote:
 On 8/6/05, A.M. Kuchling [EMAIL PROTECTED] 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.
 

Done.  rev. 1.18 .

-Brett
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com