[Tutor] file.readlines() error

BELSEY, Dylan dylan.belsey@baesystems.com
Fri, 11 Oct 2002 08:20:25 +0930


	At a quick glance, you may want to replace rtfile=file.readlines()
with lines=rtfile.readlines().  That is to say that you may be using the
wrong object for the readlines() call.


-----Original Message-----
From: McCarney, James Alexander
[mailto:James.Alexander.McCarney@Cognicase.com]
Sent: Friday, 11 October 2002 08:40
To: 'tutor@python.org'
Subject: [Tutor] file.readlines() error


Hi list,

Thanks for your answers yesterday. I am making some progress...

This is my code, that runs fine up to rtfile=file.readlines()
It wants a byte size for my file. How can I pass one in programatically?

See underneath the code for the error...


def tagfinger():
    """Finds mark-up, and prints it to a text file."""
    #imports
    import sys, string, os, os.path, glob, re
    #welcome
    print "Welcome to TagFinger!"
    print ""
    path_in=raw_input("Please type the pathname where you wish to search: ")
    print "The pathname you have chosen is: ",path_in
    print ""
    from os import chdir
    chdir(path_in)
    print "You are now in path: ",path_in
    print "We found the follwing...",glob.glob("*")
    list1=glob.glob("*")
    print ""
    answer=raw_input("Which file's tags do you wish to extract? ")
    print "You chose",answer
    for answer in list1:
        list1.pop()
    print "...Opening...",answer
    rtfile=file(answer, 'r')
    print '...Reading...',answer
    rtfile=file.readlines()  ### <<<------ Error because I cannot pass in
the byte size!

Traceback (most recent call last):
  File "<pyshell#119>", line 1, in ?
    tagfinger()
  File "C:\Documents and Settings\jamccarn\Desktop\tagfinger.py", line 24,
in tagfinger
    rtfile=file.readlines()
TypeError: descriptor 'readlines' of 'file' object needs an argument


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