[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 23:28:00 CEST 2012
On 24 September 2012 22:15, Gregory Lund <gnj091405 at gmail.com> wrote:
> >> but now get a " x = zipfile.Zipfile(item,'r')
> >> AttributeError: 'module' object has no attribute 'Zipfile' "
> >> error
> >> grrrrr, this is going to send me to the funny farm!
> >> greg
> > One way to avoid the "funny farm" is to learn to use the tools that
> > Python provides, built-in. As soon as you get an error like that one,
> > add a print statement immediately before the one in error, and find the
> > type and attributes of the object that supposedly doesn't have the
> > attribute. For example, you could have added a dir(zipfile), and then
> > studied the one that seems to be the same as the one you tried to use.
> > Presumably you would have quickly discovered what Oscar pointed out.
> Thank you, I have printed and added to my Python quick hints.
> > We all make typos, the difference is in how quickly we find and fix
> > them. Use the tools.
> must admit, I didn't notice the typo.
No but Python did when it ran your code and it tried to tell you. The trick
is to read the error message, see what line of code it occurs at and then
look very closely at that line of code and the surrounding lines of code.
The first thing to check for is a typo.
The error message that Python gives may seem cryptic but it's actually very
informative if you know how to read it. For this reason it's also more
helpful to show the *verbatim* error message when posting to this (or
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor