Dealing with exceptions
bvdp
bob at mellowood.ca
Sat Mar 2 14:39:34 EST 2013
>
> Here's a bit of a left-field thought: Maybe none of them.
>
Not far left at all :)
>
> What are you actually doing when you get an exception? Can you
>
> plausibly recover? If not - that is, if you're going to abort the
>
> whole operation anyway - then save yourself the trouble of writing the
>
> try/catch, and just let the exception propagate up (to the console, if
>
> nowhere else).
>
My first cut of the program did exactly that. Just abort the whole thing, figuring that the disk was full or buggered.
What I ran into was that half way through the process I ended up with a filename which the FAT32 didn't like. So, my brain-dead idea was to catch those (and ignore them) and continue on. But then I have to distinguish between a bad filename and "real" errors.
But, you are probably correct if you say I should check the filename first :) Is there a module for that?
More information about the Python-list
mailing list