Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103595
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Joel Goldstick <joel.goldstick@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: list index out of range Error , need to fix it or ignore it |
| Date | Sat, 27 Feb 2016 12:21:10 -0500 |
| Lines | 63 |
| Message-ID | <mailman.184.1456593680.20994.python-list@python.org> (permalink) |
| References | <CACT3xuU5L9+EbJcw+L7vySKnYO83MQQ3M4zkMLz2G85dWrBT=g@mail.gmail.com> <CACT3xuWKjiiLWRW1v+e+ySwqM7g-CiZKRD3dy2hhK4XQTzaRHA@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de agk4yi0PXJaCF5uL8vtrLg6y2alV1WezhqoquWuAzi3A== |
| Return-Path | <joel.goldstick@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; '"""': 0.05; '__name__': 0.07; 'filename': 0.07; 'main()': 0.07; 'skip:/ 10': 0.07; 'subject:Error': 0.07; 'cc:addr:python-list': 0.09; 'cmd': 0.09; 'filename.': 0.09; 'func': 0.09; 'lines:': 0.09; 'subject:ignore': 0.09; 'exception': 0.13; 'def': 0.13; "'__main__':": 0.16; '2016': 0.16; 'main():': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'typo': 0.16; '\xc2\xa0if': 0.16; 'wrote:': 0.16; 'subject:need': 0.18; 'try:': 0.18; '>': 0.18; 'email addr:gmail.com>': 0.18; 'skip:= 10': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'pass': 0.22; 'feb': 0.23; 'sat,': 0.23; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'subject:list': 0.26; 'command': 0.26; 'message- id:@mail.gmail.com': 0.27; 'idea': 0.28; 'print': 0.30; 'url:mailman': 0.30; 'run': 0.33; 'changed': 0.33; 'url:python': 0.33; 'extract': 0.33; 'traceback': 0.33; 'url:listinfo': 0.34; 'file': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'false': 0.35; 'machines': 0.35; 'there': 0.36; 'url:org': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'url:mail': 0.40; 'your': 0.60; 'skip:\xc2 10': 0.67; 'url:info': 0.71; 'to:none': 0.91; 'joel': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=x9EIXz+Lf+OgnQOAkZFw5hHJF3BvIxajCba0FCekFxY=; b=IbQWrPmumayIqPcjYLRdMxLth5ka4Hr0alIGz9uelwf6kMUhVRGOMZH4NdetQ7Shi7 9uV+MQCCuFFAu4wix3o2EZsphIRV87Wj28BUEmDN62kJKkmhnwOvnc7J8ASoH4D1ZfiK cSzTFEd6JfE9wi0jve3xBqwrWHlUkCBoKDMGQ1C0+M5T3p6Y+XFQrD+kc23SU68hP83R 9UL6+iQ28ag83ApClljc66uN63cb1F7B4KGIhoJ6r5/jzr9fcuF6Mmiyf1bOhkpySIAm im3867e4mBpRnuY8W41Y3Bt9ks4DxbR6PQDJodQqyzk2wAJaBfnd5Qd8Qf2hkQjhIec9 1HVg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=x9EIXz+Lf+OgnQOAkZFw5hHJF3BvIxajCba0FCekFxY=; b=cC+tpAVdhvc39foMqsIvtsR37jzHyFCsaDCMjleCRsafc06dGgQhZ81F9YYZ+x35ad hw+o9MQ2763GOTgloGjq3xFx5Lqf2d8cNjJQgYUAS3a9mIAhb5eFZwmSuUD3al/ZIUWy /KZFW5AdX0wmqv8SRZg+b4ZPEcl9vAF7X62EjF9KBc7U04Z3Vd16qetdaQ8e8I1kP3SU bMcR8McUXFBsoM1KMtjn1HXhZJ50En96O3BDIu7uddXvqzzXF9mDg2ylq4xd8ZodSoUv esA4jfMJCG7Qnh3Z/FUf3nltaTmuA08jM10v3355MkChsa2OFmIqp0orb/ir54wDkF9f 12nw== |
| X-Gm-Message-State | AD7BkJI0ABvYuhBNeEwRPSj+bXE1IEzpkq2KRJZp4uu7FtrOWDPfQ3Dpm5v3buYavzBR5GWDFRCufRFbjWpU8g== |
| X-Received | by 10.50.143.102 with SMTP id sd6mr2932310igb.73.1456593670797; Sat, 27 Feb 2016 09:21:10 -0800 (PST) |
| In-Reply-To | <CACT3xuWKjiiLWRW1v+e+ySwqM7g-CiZKRD3dy2hhK4XQTzaRHA@mail.gmail.com> |
| X-Content-Filtered-By | Mailman/MimeDel 2.1.21rc2 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:103595 |
Show key headers only | View raw
On Sat, Feb 27, 2016 at 12:01 PM, Ganesh Pal <ganesh1pal@gmail.com> wrote:
> changed baddr="" to file ="" in the example program , sorry for the typo
>
> > filename='/tmp2/2.txt'
> >
> > def check_file():
>
don't use global filename. just pass filename into check_file
def check_file(filename):
> > """
> > Run the command parallel on all the machines , if there is a
> > file named /tmp/file2.txt extract file2.txt
> >
> > """
> > global filename
> > file = ''
> > cmd = ("run_al_paral 'ls -al %s'" % (filename))
> > print(cmd)
> > stdout, stderr, exitcode = run(cmd)
>
what is run(...)
> > print(stdout)
> > lines = stdout.strip().split('\n')
> > print(lines)
> > for line in lines:
> > if 'exited' in lines:
> > continue
> >
> > file = lines[0].split()[9][6:]
> > break
> > print file
> > return file
> >
> > def main():
> > functions = [check_file]
> > for func in functions:
> > try:
> > func()
> > except Exception as e:
>
not a good idea to have catchall exception
> > return False
> > if __name__ == '__main__':
> > main()
> >
> --
>
copy and paste your traceback
> https://mail.python.org/mailman/listinfo/python-list
>
--
Joel Goldstick
http://joelgoldstick.com/ <http://joelgoldstick.com/stats/birthdays>
http://cc-baseballstats.info/
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: list index out of range Error , need to fix it or ignore it Joel Goldstick <joel.goldstick@gmail.com> - 2016-02-27 12:21 -0500
csiph-web