Puzzling error msg.
wrw at mac.com
wrw at mac.com
Mon Dec 3 13:32:10 EST 2012
On Dec 3, 2012, at 1:12 PM, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
> 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 =
> Google.connection_test()
>> File "/Users/wrw/Dev/Python/Connection_Monitor/Version2.2/WorkingCopy/
> network.py",
>> 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.
>
Steven, thanks for looking at this. No, I'm not using -x and the .py and .pyc files are as they should be. (Notice in the traceback that the files were in the "Version2.2/WorkingCopy/" directory. I'm pretty careful
about version control.) I've added a bunch of print statements and I'll just have to wait until it fails again - hopefully soon.
>
>
> 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:
>
>
[byte]
> 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".
>
>
OK - point taken wrt testing booleans.
> --
> Steven
> --
> http://mail.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list