[Tutor] Unusual behavior in readline

Tony Cappellini cappy2112 at gmail.com
Tue Aug 8 18:00:59 CEST 2006


I don't understand why readline is producing such unusual behavior.
I don't remember it working like this previously. The docs say it is
supposed to read a line at a time.

this function

def ProcessFile(self, Inputfile, Outputfile=None):

        try:
            fh=open(Inputfile,"r")
        except IOError:
            print"\nError ocurred opening %s for input\n" % Inputfile
        else:
            FixedEntry = []
            Entry = ""
            for Entry in fh.readline():
                print"Entry = %s" % Entry

            fh.close()

is producing this result

Entry = A
Entry = l
Entry = i
Entry = a
Entry = s
Entry = ,
Entry = P
Entry = h
Entry = o
Entry = n
Entry = e

With this input file
Alias,Phone
JANE SMITH,12131234567

Readline is supposed to read an entire line on each call, yet it is only
reading one character.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060808/d7f7e0a7/attachment.htm 


More information about the Tutor mailing list