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


Groups > comp.lang.python > #77829 > unrolled thread

find the error

Started bydaoudimca@gmail.com
First post2014-09-12 22:47 -0700
Last post2014-09-13 19:26 -0400
Articles 5 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  find the error daoudimca@gmail.com - 2014-09-12 22:47 -0700
    Re: find the error Chris Angelico <rosuav@gmail.com> - 2014-09-13 15:53 +1000
      Re: find the error Andrea D'Amore <anddamNOALPASTICCIODICARNE+gruppi@brapi.net> - 2014-09-13 08:43 +0200
    Re: find the error Denis McMahon <denismfmcmahon@gmail.com> - 2014-09-13 17:28 +0000
    Re:find the error Dave Angel <davea@davea.name> - 2014-09-13 19:26 -0400

#77829 — find the error

Fromdaoudimca@gmail.com
Date2014-09-12 22:47 -0700
Subjectfind the error
Message-ID<70d7bef7-6393-41e1-b4e0-a5d3a6630063@googlegroups.com>
Dear friends when i used 
import urllib, re, sys

symbol = sys.argv[1] >>> this function is show -->> symbol = sys.argv[1]
IndexError: list index out of range 

kindly find the solution of this

[toc] | [next] | [standalone]


#77830

FromChris Angelico <rosuav@gmail.com>
Date2014-09-13 15:53 +1000
Message-ID<mailman.13989.1410587619.18130.python-list@python.org>
In reply to#77829
On Sat, Sep 13, 2014 at 3:47 PM,  <daoudimca@gmail.com> wrote:
> Dear friends when i used
> import urllib, re, sys
>
> symbol = sys.argv[1] >>> this function is show -->> symbol = sys.argv[1]
> IndexError: list index out of range
>
> kindly find the solution of this

If you're using sys.argv, you need to provide arguments to your
script. You provided no arguments, so the list doesn't have elements
for you to find.

ChrisA

[toc] | [prev] | [next] | [standalone]


#77833

FromAndrea D'Amore <anddamNOALPASTICCIODICARNE+gruppi@brapi.net>
Date2014-09-13 08:43 +0200
Message-ID<lv0p1n$ml7$1@virtdiesel.mng.cu.mi.it>
In reply to#77830
On 2014-09-13 05:53:37 +0000, Chris Angelico said:

> If you're using sys.argv, you need to provide arguments to your
> script.

Or check sys.argv's length ensuring that an element is there before 
accessing it.


-- 
Andrea

[toc] | [prev] | [next] | [standalone]


#77851

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2014-09-13 17:28 +0000
Message-ID<lv1urj$mpf$1@dont-email.me>
In reply to#77829
On Fri, 12 Sep 2014 22:47:57 -0700, daoudimca wrote:

> Dear friends when i used import urllib, re, sys
> 
> symbol = sys.argv[1] >>> this function is show -->> symbol = sys.argv[1]
> IndexError: list index out of range
> 
> kindly find the solution of this

You are trying to reference more elements than your list contains.

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#77852

FromDave Angel <davea@davea.name>
Date2014-09-13 19:26 -0400
Message-ID<mailman.14001.1410650691.18130.python-list@python.org>
In reply to#77829
daoudimca@gmail.com Wrote in message:
> Dear friends when i used 
> import urllib, re, sys
> 
> symbol = sys.argv[1] >>> this function is show -->> symbol = sys.argv[1]
> IndexError: list index out of range 
> 
> kindly find the solution of this
> 

sys.argv is filled in from the command line arguments.  Perhaps
 your script should protect itself by majing sure len (sys.argv)
 is what's required,  in this case at least 2.  That way the user
 gets a friendlier message when he omits the arguments.
 

By the way, you should simply copy/paste the entire stack trace.
 When you paraphrase,  you're likely to have a typo, or omit
 something useful.

-- 
DaveA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web