[Tutor] zip question

D. Hartley denise.hartley at gmail.com
Tue May 10 03:28:54 CEST 2005


Hey everyone - 

I finally got it. Just did a.filename, or a.comment or whatever. I
think I was feeling like if it wasnt a method, I couldnt make it
display.  Then I typed in a.filename, and it popped up "file.txt"
right there in the interpreter window and I felt like a big idiot. Why
couldn't that have been one of the ten things I tried *before* I sent
the email? ha ha.  Since this is my first language (re:john's
comment), I am still having trouble keeping all the jargon straight -
have to remember the differences between functions and methods and
attributes and instances and fifteen hundred other words I'm not used
to worrying about much ;)

Thanks again for all your help everyone, I finally solved the riddle
(!!!) and am onto the next one! And here I thought I'd be stuck ;)

~Denise

On 5/9/05, jfouhy at paradise.net.nz <jfouhy at paradise.net.nz> wrote:
> Quoting "D. Hartley" <denise.hartley at gmail.com>:
> 
> > Instances have the following attributes:
> >
> > filename, comment, etc.
> >
> >
> > I've tried about ten things to get "filename" to work:
> >
> > myzip.filename("99905.txt") (str not callable)
> 
> Check out the error message: "str not callable".  You are trying to call
> something whose type is "str" --- ie: a string.  In python, there is no
> distinction between callable and noncallable attributes.
> 
> try:
> >>> print myzip.filename
> It should print the filename that this ZipInfo object refers to.
> 
> Likewise, myzip.comment is a string which is the comment attached to the file in
> the zip.
> 
> If you have any background in other languges, it might help you to think of
> these as "member variables" (or whatever they call them).  And a ZipInfo object
> appears to be similar to a struct in C/C++.
> 
> I hope this helps.
> (and if it doesn't, the fault is probably in the explanation, so keep asking,
> and I (or someone else) will try again :-) )
> 
> --
> John.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list