[Tutor] Cannot fix OSError (try/except)
Lloyd Kvam
pythontutor at venix.com
Sat Jan 31 14:00:11 EST 2004
You can pass the name of a directory. If it can't read a file within
the directory, it abandons the rest of the directory contents. I just
tested that. The except will continue to the next file/directory in YOUR
list, but you've potentially skipped readable files in the directory with
an error.
Alan Gauld wrote:
> LLoyd,
>
>
>>Is there any way a try/except at this level could complete building
>
> the tar file
>
>>while only omitting the unreadable files? It seems to me that only
>
> a try/except
>
>>in the tarfile module could actually finish building the best
>
> possible tar
>
> I thought the code I posted would do that?
>
> # open tarfile up here
>
> for f in filelist:
> try: tarfile.TarFile.add()
> except OSERror: print 'couldn't add', f
>
> # close tarfile down here
>
>
>
>>Am I missing something?
>
>
> Maybe, or maybe it's me that missing something?
>
>
> Alan G.
>
>
--
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358
voice: 603-653-8139
fax: 801-459-9582
More information about the Tutor
mailing list