How do I continue after the error?

Ben Finney ben+python at benfinney.id.au
Thu Jun 4 22:01:56 EDT 2009


chad <cdalten at gmail.com> writes:

> Let's say I have a list of 5 files. Now lets say that one of the files
> reads nude333.txt instead of nude3.txt. When this happens, the program
> generates an error and quits. What I want it to do is just skip over
> the bad file and continue on with the next one.

Have you worked thoroughly through the Python tutorial
<URL:http://docs.python.org/tutorial/>? You will exercise many
fundamental concepts, including the exception handling system.

> Below is the actual code. It only works on the local bbs that I hang
> out on. Sorry. I couldn't think of the simple case that could isolate
> my problem.

You achieve this by one of two methods:

* start with a program that does extermely little, and add as little as
  possible until you have a very small program which demonstrates the
  behaviour. Once you have this, continue below.

* remove apparently-irrelevant parts from the program until the
  behaviour stops occuring; the most recent removal, then, is at least
  related to the behaviour. Add it back in.

Repeat these until you have aprogram which can't have any part of it
removed without losing the behaviour that's confusing you. Once you have
that, post it here with your question.

-- 
 \        “Good morning, Pooh Bear”, said Eeyore gloomily. “If it is a |
  `\   good morning”, he said. “Which I doubt”, said he. —A. A. Milne, |
_o__)                                                _Winnie-the-Pooh_ |
Ben Finney



More information about the Python-list mailing list