Dealing with exceptions

Chris Angelico rosuav at gmail.com
Sat Mar 2 23:16:51 CET 2013


On Sun, Mar 3, 2013 at 8:23 AM, Terry Reedy <tjreedy at udel.edu> wrote:
>>>> open('sdjhfjshdfkjsh')
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in <module>
>     open('sdjhfjshdfkjsh')
> FileNotFoundError: [Errno 2] No such file or directory: 'sdjhfjshdfkjsh'
>
> Now, does shutil pass on FileNotFoundError? I will let you experiment.
>
> There are error conditions that are hard to generate, but a bad file name is
> not one of them.

That's actually a perfectly valid file name, but one that doesn't
happen to have a corresponding file. However, the same technique will
work with the OP's description of "a filename which the FAT32 didn't
like" too.

ChrisA



More information about the Python-list mailing list