Re: Puzzling error msg.
On Mon, 03 Dec 2012 12:37:42 -0500, wrw wrote:
> So far in my experience with Python, it's error messages have been
> clear, concise, and quite good at fingering my errors. However, the
> message below has me stumped. The routine in question has been running
> for weeks with no problems, then yesterday I got the following:
> Traceback (most recent call last):
> File "./Connection_Monitor.py", line 146, in <module>
> Google_up, Google_summary, Google_RTT, Google_stddev =
> File "/Users/wrw/Dev/Python/Connection_Monitor/Version2.2/WorkingCopy/
> line 101, in connection_test
> IndexError: list index out of range
Are you running Python with the -x option? If so, then I understand that
the line number (and subsequent line of code) reported in tracebacks may
sometimes be off by one.
If not, or if the discrepancy is more than one line, I would start
investigating the following scenario:
* there is a mismatch between the source code .py file and the
byte-code .pyc file;
* but the .pyc file's "last modified date" is newer than the .py file;
* the .pyc file is executed (as is usual);
* but when an error occurs and Python looks up the source file, it
gets something which no longer corresponds to the byte-code being
By the way, in connection_test you have the following:
> def connection_test(self):
> found_0 = '0 packets received' in ping_result
> found_1 = '1 packets received' in ping_result
> if found_0 == True or found_1 == True:
Of course that's not correct. You should write:
if (found_0 == True or found_1 == True) == True:
No wait, I mean:
if ((found_0 == True or found_1 == True) == True) == True:
No wait! I meant this:
if ((found_0 == True == True == True == True == ... # Help!
or found_1 == True == True == True == True == ... # Where do I stop?
) == True) == True == True == True == True ... :
Of course the whole thing is silly. The right way to test booleans for
their boolean value is just:
if found_0 or found_1:
"flag == True" is the same as "flag".
|All times are GMT. The time now is 08:27 AM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.