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


Groups > comp.lang.python > #38173

Re: error in except

References <CABRP1o-UkR9j3Ry+xYgpFobAo0yETVvy_8pUm4UYZQO0=rSEAw@mail.gmail.com> <1360025881.32270.140661186861365.09CB02A5@webmail.messagingengine.com> <CAFtnWG8cdfJVKBoZKR=f2mDrR6M7S7mtOnNY+dcuHAAWoWP1BA@mail.gmail.com>
Date 2013-02-05 18:55 +1100
Subject Re: error in except
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1358.1360050908.2939.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Feb 5, 2013 at 5:51 PM, Laxmikant Chitare
<laxmikant.general@gmail.com> wrote:
> One more thing, apart from what Albert mentioned.
> Exceptions must be classes or instances. In effect you cannot just do
> 'raise'. 'raise' statement must be followed by a class or an instance.

You can inside an except clause.

>>> try:
	1/0
except:
	print("I got an exception!")
	raise

I got an exception!
Traceback (most recent call last):
  File "<pyshell#5>", line 2, in <module>
    1/0
ZeroDivisionError: division by zero


ChrisA

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


Thread

Re: error in except Chris Angelico <rosuav@gmail.com> - 2013-02-05 18:55 +1100

csiph-web