Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
syntax to continue into the next subsequent except block
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 26 - 32 of 32 - Collapse all  -  Translate all to Translated (View all originals) < Older 
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jim Jewett  
View profile  
 More options Sep 17 2012, 3:34 pm
From: Jim Jewett <jimjjew...@gmail.com>
Date: Mon, 17 Sep 2012 15:33:20 -0400
Local: Mon, Sep 17 2012 3:33 pm
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block
On 9/17/12, Guido van Rossum <gu...@python.org> wrote:

> I don't think I've
> ever had a use case in my own code where I found it particularly
> awkward that I couldn't jump from one except clause to the next;

I have had cases where I wanted to either
(1)  Say "oops, not really a match, keep looking at the other except clauses"

The except ... if answers this, but I do think virtual subclasses
would be a better solution.  In my case, I would have created a
subclass for file errors that could be fixed automatically.

(2)  If there is an exception [of such and such a type] do X, but
sometimes *also* do Y.

The continue could answer this, but I'm not convinced it would smell
any less than the current workarounds.

-jJ
_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jim Jewett  
View profile  
 More options Sep 17 2012, 3:40 pm
From: Jim Jewett <jimjjew...@gmail.com>
Date: Mon, 17 Sep 2012 15:39:50 -0400
Local: Mon, Sep 17 2012 3:39 pm
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block
On 9/16/12, Joshua Landau <joshua.landau...@gmail.com> wrote:

> On 16 September 2012 23:30, Cameron Simpson <c...@zip.com.au> wrote:
>> Having a ridiculous suite of a billion trite
>> subclasses to enumerate the return codes from a lower level (or more
>> "inner") library is just nuts.

If the library created them, it is distinguishing between them --
regardless of whether it distinguishes by name or by number.

> As said above, how is Library.MathError(5) more arbitrary than
> Library.UncalculatableMathError()?

Numbers are more likely to get shifted by accident when someone adds a
new value.

But the point isn't that codes are more arbitrary -- it is that a name
is more helpful when debugging.

> Yes, if you have an incomplete name list you will suffer. But so what? Just
> cover all your bases. If you are wrapping a program from a lower-level
> language, wrap *everything you need*. It's no different to any other aspect
> of wrapping libraries.

And, more to the point, wrap *only* what you need.  If you were
providing the sole wrapper for a library, then you might have a fairly
long translation list.  But if you're just using the library, only
create virtual subclasses for the conditions that you happen to care
about, and name them based on why they matter.

-jJ
_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joshua Landau  
View profile  
 More options Sep 17 2012, 4:02 pm
From: Joshua Landau <joshua.landau...@gmail.com>
Date: Mon, 17 Sep 2012 21:00:42 +0100
Local: Mon, Sep 17 2012 4:00 pm
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block

On 17 September 2012 20:39, Jim Jewett <jimjjew...@gmail.com> wrote:

> On 9/16/12, Joshua Landau <joshua.landau...@gmail.com> wrote:
> > On 16 September 2012 23:30, Cameron Simpson <c...@zip.com.au> wrote:
> > As said above, how is Library.MathError(5) more arbitrary than
> > Library.UncalculatableMathError()?

> Numbers are more likely to get shifted by accident when someone adds a
> new value.

> But the point isn't that codes are more arbitrary -- it is that a name
> is more helpful when debugging.

And I totally agree. My original post was meant to say "how is *
Library.UncalculableMathError()* more arbitrary than *Library.MathError(5)*?"
as a refute to a claim that they are. Thanks for catching that.

_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen J. Turnbull  
View profile  
 More options Sep 17 2012, 9:08 pm
From: "Stephen J. Turnbull" <step...@xemacs.org>
Date: Tue, 18 Sep 2012 10:08:54 +0900
Local: Mon, Sep 17 2012 9:08 pm
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block

Steven D'Aprano writes:

 > I don't think [the existing syntax] is quite awkward.

Of course it is.  It doesn't fit the semantics, and that is why it is
awkward.  An exception should be caught by an 'except' clause, not by
a conditional statement.  As Antoine's refactoring demonstrates, these
Exceptions that are differentiated by an internal errno are often
conceptually a variety of different exceptions.  I agree with the
suggestion that really we should fix up other Exceptions that are
clearly quite heterogeneous by subclassing more precise exceptions
from them.

But this isn't always possible, and of course may not be backward
compatible.

I don't know how to do it Pythonically, but it would be nice if there
were some way to "subclass Exceptions on the fly".

(other) Steve
_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nick Coghlan  
View profile  
 More options Sep 18 2012, 2:56 am
From: Nick Coghlan <ncogh...@gmail.com>
Date: Tue, 18 Sep 2012 16:55:16 +1000
Local: Tues, Sep 18 2012 2:55 am
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block
On Tue, Sep 18, 2012 at 11:08 AM, Stephen J. Turnbull

<step...@xemacs.org> wrote:
> I don't know how to do it Pythonically, but it would be nice if there
> were some way to "subclass Exceptions on the fly".

Most likely, this will mean fixing the bug that means the ABC
machinery is currently being ignored by the exception machinery. Then
you can do whatever you want to reshape exception hierarchies.

Cheers,
Nick.

--
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chris Kaynor  
View profile  
 More options Sep 18 2012, 1:01 pm
From: Chris Kaynor <ckay...@zindagigames.com>
Date: Tue, 18 Sep 2012 10:00:06 -0700
Local: Tues, Sep 18 2012 1:00 pm
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block

On Mon, Sep 17, 2012 at 11:55 PM, Nick Coghlan <ncogh...@gmail.com> wrote:
> On Tue, Sep 18, 2012 at 11:08 AM, Stephen J. Turnbull
> <step...@xemacs.org> wrote:
>> I agree with the suggestion that really we should fix up other Exceptions that are clearly quite heterogeneous by subclassing more precise exceptions from them.
>> But this isn't always possible, and of course may not be backward compatible.

If done well, it should be fully backwards compatible. There is not
reason that you cannot keep the errno (or however its named on the
specific exception class) while still subclassing the exception.

You could have issues with pickled exceptions if you add more details
to the exceptions, and it is not forward compatible: newer code that
gets the older form of exceptions is liable to break, without extreme
care to update the exceptions.

>> I don't know how to do it Pythonically, but it would be nice if there
>> were some way to "subclass Exceptions on the fly".

> Most likely, this will mean fixing the bug that means the ABC
> machinery is currently being ignored by the exception machinery. Then
> you can do whatever you want to reshape exception hierarchies.

One trick we've done at work in a few cases is to put a fairly thin
wrapper around the low-level apis that wrap the exceptions into
subclasses. Often, this can be implemented as a simple decorator that
then can be used on a series of functions easily.

> Cheers,
> Nick.

> --
> Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
> _______________________________________________
> Python-ideas mailing list
> Python-id...@python.org
> http://mail.python.org/mailman/listinfo/python-ideas

_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stephen J. Turnbull  
View profile  
 More options Sep 20 2012, 5:18 am
From: "Stephen J. Turnbull" <step...@xemacs.org>
Date: Thu, 20 Sep 2012 18:17:34 +0900
Local: Thurs, Sep 20 2012 5:17 am
Subject: Re: [Python-ideas] syntax to continue into the next subsequent except block

Chris Kaynor writes:

 > On Mon, Sep 17, 2012 at 11:55 PM, Nick Coghlan <ncogh...@gmail.com> wrote:
 > > On Tue, Sep 18, 2012 at 11:08 AM, Stephen J. Turnbull
 > > <step...@xemacs.org> wrote:
 > >> I agree with the suggestion that really we should fix up other
 > >> Exceptions that are clearly quite heterogeneous by subclassing
 > >> more precise exceptions from them.  But this isn't always
 > >> possible, and of course may not be backward compatible.
 >
 > If done well, it should be fully backwards compatible. There is not
 > reason that you cannot keep the errno (or however its named on the
 > specific exception class) while still subclassing the exception.

Of course that's backward compatible with old code receiving the new
subclassed exceptions.  Maybe I misused the term "backward
compatible", but what I meant was that it's likely to be the case that
the person doing the subclassing will unify groups of error codes he
believes unlikely to need distinguishing in Python applications
(vs. more low-level languages).  Eg, I don't see more than one hundred
new Exceptions in PEP 3151, but only a handful (about 15).

_______________________________________________
Python-ideas mailing list
Python-id...@python.org
http://mail.python.org/mailman/listinfo/python-ideas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages < Older 
« Back to Discussions « Newer topic     Older topic »