bvdp wrote:
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match:
raise StopInteration()
else ...
except StopInteration:
print found it
I prefer
On 3/12/12 10:37 AM, Jean-Michel Pichavant wrote:
bvdp wrote:
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match:
raise StopInteration()
else ...
except StopInteration:
print found it
I prefer
On 11/03/12 19:04, bvdp wrote:
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match:
raise StopInteration()
else ...
except StopInteration:
print
On Tue, Mar 13, 2012 at 12:06 AM, James Elford fil.ora...@gmail.com wrote:
I wonder whether you need to use an exception here rather than a yield
statement?
Or a return statement, if you're not needing multiple responses.
ChrisA
--
http://mail.python.org/mailman/listinfo/python-list
Irmen de Jong, 11.03.2012 21:37:
On 11-3-2012 20:04, bvdp wrote:
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match:
raise StopInteration()
else
On Mon, 12 Mar 2012 14:52:49 +0100, Stefan Behnel wrote:
raise X is a special case of the 3-args raise. Effectively it just
raises an instance of X which is constructed with an empty argument
list. Therefore, raise X() is equivalent, as far as I know.
Not completely, although that may
Steven D'Aprano, 12.03.2012 16:08:
On Mon, 12 Mar 2012 14:52:49 +0100, Stefan Behnel wrote:
raise X is a special case of the 3-args raise. Effectively it just
raises an instance of X which is constructed with an empty argument
list. Therefore, raise X() is equivalent, as far as I know
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match:
raise StopInteration()
else ...
except StopInteration:
print found it
--
http://mail.python.org/mailman
On 11-3-2012 20:04, bvdp wrote:
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match:
raise StopInteration()
else ...
except StopInteration
On Sun, Mar 11, 2012 at 1:37 PM, Irmen de Jong irmen.nos...@xs4all.nl wrote:
On 11-3-2012 20:04, bvdp wrote:
Which is preferred in a raise: X or X()? I've seen both. In my specific case
I'm dumping out of a deep loop:
try:
for ...
for ...
for ...
if match
On Sun, 11 Mar 2012 12:04:55 -0700, bvdp wrote:
Which is preferred in a raise: X or X()?
Both.
Always use raise X(*args) when you need to provide arguments (which you
should always do for exceptions meant for the caller to see). The form
raise X, args should be considered discouraged
Thanks all for the comments.
Personally, I used raise X to mean this doesn't need arguments and
should never have any and raise X() to mean this needs arguments but
I'm too lazy to provide them right now. Think of it as a FIXME.
Yes, that makes as much sense as anything else :)
--
http
On 11/03/2012 23:59, Steven D'Aprano wrote:
On Sun, 11 Mar 2012 12:04:55 -0700, bvdp wrote:
Which is preferred in a raise: X or X()?
Both.
Always use raise X(*args) when you need to provide arguments (which you
should always do for exceptions meant for the caller to see). The form
raise X
13 matches
Mail list logo