Re: error in except

Discussion in 'Python' started by Chris Angelico, Feb 5, 2013.

  1. On Tue, Feb 5, 2013 at 5:51 PM, Laxmikant Chitare
    <> 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
    Chris Angelico, Feb 5, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Salerno
    Replies:
    20
    Views:
    809
    John Salerno
    Aug 11, 2006
  2. Fabio Z Tessitore

    who is simpler? try/except/else or try/except

    Fabio Z Tessitore, Aug 12, 2007, in forum: Python
    Replies:
    5
    Views:
    356
  3. David House

    try -> except -> else -> except?

    David House, Jul 6, 2009, in forum: Python
    Replies:
    2
    Views:
    316
    Bruno Desthuilliers
    Jul 6, 2009
  4. Peng Yu
    Replies:
    1
    Views:
    494
    Steven D'Aprano
    Nov 18, 2009
  5. MRAB
    Replies:
    0
    Views:
    803
Loading...

Share This Page