list.index crashes when the element is not found

TkNeo tarun.kap at gmail.com
Fri May 2 16:35:30 EDT 2008


On May 2, 3:09 pm, George Sakkis <george.sak... at gmail.com> wrote:
> On May 2, 3:04 pm, TkNeo <tarun.... at gmail.com> wrote:
>
>
>
> > On May 2, 1:58 pm, Nick J Chackowsky <mediocre_per... at hotmail.com>
> > wrote:
>
> > > TkNeo wrote:
> > > > WHAT ?
>
> > > > This is crazy
>
> > > Crazy like a fox?
>
> > > a = [1, 2, 3]
> > > try:
> > >      a.index(99)
> > > except:
> > >      a.append(99)
> > > finally:
> > >      print a.index(99)
>
> > > MY question: which exception should I actually be catching there?
> > > ** Posted fromhttp://www.teranews.com**
>
> > ofcouse try catch is going to work but in ideality the index function
> > should return a -1 and no way in hell crash.
>
> Please refrain from making such inane comments after an hour or two of
> toying with a new language. Read a good tutorial first (e.g.http://diveintopython.org/toc/index.html) and come back if you have a
> real question.
>
> George

George - I am not trying to be negative in any way whatsoever.

0 - In my first post in this thread, i was just being sarcastic.
1- I have been using python for more than an year or so. Just not an
avid user as probably you are.
2. You suggest me to ask a "REAL" question. Real is a relative word.
What is real to you might not be real to lets say Guido van Rossum. I
met him a few months ago and he was very humble to all the stupid
questions i had.
3  The board does not specify the level of python developers who can
post questions.
4 -I have always heard that python community is based on sharing and
helping each other. Please keep those spirits up.

Thanks for replying and sorry for wasting your time.
TK




More information about the Python-list mailing list