This is a problem I'm having with instances of classes and their
objects.  John suggested:

> Look at the constructor :-)
>
> >>> import zipfile
> >>> z = zipfile.ZipFile('myzip.zip')
> >>> z.printdir()

I admitted that my grasp of classes (and "constructors") is a bit
fuzzy. I did get this particular class to work, and got the first half
of the problem done.  However, now i'm working in another class,
zipinfo.  It says:

Instances of the ZipInfo class are returned by the getinfo() and
infolist() methods of ZipFile objects. Each object stores information
about a single member of the ZIP archive.

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)
myzip.comment(file("99905.txt")) (no file with this name - i suppose,
if it's still zipped?)

myzip.getinfo(99905.txt) (invalid syntax)

and, trying to do this one the same way as the zipfile one (a long shot):
mynote = zipfile.ZipInfo("channel.zip")
>>> mynote
<zipfile.ZipInfo instance at 0x0174CB48>
mynote.filename(file("99905.txt")) (again, no such file name)

i know this trial-and-error method is sloppy, trying to find the right
format, but i'm still getting used to dot notations and modules and
classes and so on - was trying to figure out a way to make it work
without having to ask and feel dumb, ha ha.

Does anyone have a (hopefully simple) explanation of how to format
this command? I'd really appreciate it!

Thanks,
Denise
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to