[Tutor] Basic newbie questions
Sean 'Shaleh' Perry
shalehperry@attbi.com
Wed, 06 Mar 2002 14:32:10 -0800 (PST)
>
> In this example, I tried running "tracert.py" and got the following
> error msg:
>
> Traceback (most recent call last):
> File "C:\PYTHON22\tracert.py", line 96, in ?
> compress()
> File "C:\PYTHON22\tracert.py", line 84, in compress
> d=cPickle.load(open(fn))
> IOError: [Errno 2] No such file or directory: 'stats.dat'
>
> I'm not concerned about the error so much as what I am missing in terms
> of things I must specify to make a program work. Should this program
> have worked, is this one of those revision bugs, or did I not do
> something??
>
This is looking for a stats.dat file which should have been created by
something. What item from parnassus gave you tracert.py?
> Last question:
>
> Where can I read or see examples of doing File I/O?? Specifically, how
> to designate a drive to read a file from and how to read the file(s).
> I realize I have along way to go but I can't get passed this tracert
> program not working; mentally.
> I'll appreciate any help.
>
>>> f = open('apt.howto')
>>> f.readline()
'Apt is a suite of utilities that assist the admin in maintaining an\n'
>>> n = f.readline()
>>> print n
up-to-date system. More in depth documentation can be found in apt(8),
>>> count = 0
>>> for line in f.readlines(): count = count + 1
...
>>> print count
35
>>> f.close()