Re: Error .. Please Help

Discussion in 'Python' started by Neil Cerutti, Dec 13, 2012.

  1. Neil Cerutti

    Neil Cerutti Guest

    On 2012-12-13, inshu chauhan <> wrote:
    > For this I put an else clause at end but is there a better way
    > to avoid this kind of situation ??


    An if-elif-else structure is usually broken if you leave out the
    else part. When I don't expect it to ever actually happen when
    the program is working correctly it looks like this:

    else:
    raise SomeException("{} can't happen!".format(the_context))

    else: raise exception constructs have saved me a lot of time.

    --
    Neil Cerutti
     
    Neil Cerutti, Dec 13, 2012
    #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. Replies:
    4
    Views:
    570
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    731
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,830
    Mike Hewson
    Jan 7, 2005
  4. Replies:
    4
    Views:
    338
    Martin Ambuhl
    Nov 14, 2007
  5. mera
    Replies:
    7
    Views:
    1,159
Loading...

Share This Page