[Tutor] print problem

Walter Prins wprins at gmail.com
Sat Dec 4 02:42:23 CET 2010


Please post the exact contents of "test_script_test.py", don't paraphrase,
don't abbreviate. A good place to post code snippets are here:
http://pastebin.com/

That said, I'll try to put down some of the troubleshooting thought process
you should be having.

Firstly, the error message is telling you that on line 14 of your module on
the line saying "newk = dat[mystartl:myfinish]", that "mystartl" is not
defined.

So then you should be asking yourself "how can it happen that the program
can get to this point and 'mystartl' not be set?".

Which should lead on to "OK, let's see where mystart is in fact being set,
and see if there's conditions attached to that which may explain the
behaviour".

Which should lead to you looking back in the code and spotting the lines
that says:
...         if dat[i].startswith('BEGIN LINE'):
...                 mystartl = i

OK, so: "mystartl" is *only* set if dat[i].startswith('BEGIN LINE') is
false.

So then the implication would be that dat[i] doesn't start with 'BEGIN LINE'
when run from the prompt, so the next question would be why that is?

The implication would be that it wasn't read from the file.

So then implication is that the file "test" that your script reads is not
what you think it is when you run the file from the prompt.

HTH,

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101204/46c647d1/attachment.html>


More information about the Tutor mailing list