Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53031

Re: How come StopIteration.__base__ is not BaseException?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail
From Marco Buttu <marco.buttu@gmail.com>
Newsgroups comp.lang.python
Subject Re: How come StopIteration.__base__ is not BaseException?
Date Tue, 27 Aug 2013 08:17:15 +0200
Organization Aioe.org NNTP Server
Lines 16
Message-ID <521C446B.9040605@gmail.com> (permalink)
References <kvgapp$lh3$1@speranza.aioe.org> <mailman.246.1377547832.19984.python-list@python.org>
NNTP-Posting-Host V1zDWF+zqlPRb/IZhVxPcQ.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.python:53031

Show key headers only | View raw


On 08/26/2013 10:10 PM, random832@fastmail.us wrote:

> The reason KeyboardInterrupt and SystemExit inherit from BaseException
> is because you often want them to escape (allowing the program to quit)
> from code that would otherwise catch them (by catching Exception). On
> the contrary, StopIteration is almost always used in a context that
> catches it specifically.

But if I want to catch it specifically (except BaseIteration), why
doesn't it hinerit directly from BaseException? It's not an error and 
it's not a warning. I would like to see a piece of code in which it is
useful to catch it generically with a except Exception clause instead of 
an except StopIteration...
Regards
-- 
Marco

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How come StopIteration.__base__ is not BaseException? Marco Buttu <marco.buttu@gmail.com> - 2013-08-26 21:37 +0200
  Re: How come StopIteration.__base__ is not BaseException? random832@fastmail.us - 2013-08-26 16:10 -0400
    Re: How come StopIteration.__base__ is not BaseException? Marco Buttu <marco.buttu@gmail.com> - 2013-08-27 08:17 +0200
      Re: How come StopIteration.__base__ is not BaseException? Marco Buttu <marco.buttu@gmail.com> - 2013-08-27 08:18 +0200
      Re: How come StopIteration.__base__ is not BaseException? Steven D'Aprano <steve@pearwood.info> - 2013-08-27 09:22 +0000
        Re: How come StopIteration.__base__ is not BaseException? Marco Buttu <marco.buttu@gmail.com> - 2013-08-27 12:02 +0200
          Re: How come StopIteration.__base__ is not BaseException? Terry Reedy <tjreedy@udel.edu> - 2013-08-27 14:51 -0400
            Re: How come StopIteration.__base__ is not BaseException? Marco Buttu <marco.buttu@gmail.com> - 2013-08-27 21:52 +0200
              Re: How come StopIteration.__base__ is not BaseException? Terry Reedy <tjreedy@udel.edu> - 2013-08-27 16:37 -0400
  Re: How come StopIteration.__base__ is not BaseException? Ethan Furman <ethan@stoneleaf.us> - 2013-08-27 13:00 -0700

csiph-web