[Tutor] Unzipping a Zip of folders that have zips within them that I'd like to unzip all at once.
oscar.j.benjamin at gmail.com
Mon Sep 24 03:34:47 CEST 2012
On 24 September 2012 02:22, Gregory Lund <gnj091405 at gmail.com> wrote:
> > You're trying to open the directory as if it were a zipfile. You should
> > pass in the path to a zipfile not to a folder.
> Agreed, but how do I do that "pass in the path to a zipfile'?
> Using an if statement I presume?
> > >
> > > I guess my first issue is to resolve the 'Permission denied' problem.
> > > And, I know I need an 'if' statement, somehow...
> Yes, the permission denied problem seems to be the first real
> obstacle, but I can't figure it out.
> I tried searching online but everything I found to try, didn't work.
The permission error is because you are trying to open a folder as if it
were a file. The operating system does not give you permission to do this
because it is a nonsensical operation.
> Remove the folder paths from the list of paths.
> How can I remove the folder paths from the list of paths?
You can do it with a list comprehension:
paths = [p for p in paths if os.path.isdir(p)]
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor