[Tutor] readlines() ... problem [komodo weirdness / choose good variable names]

James Roberts James@BlahBlahJsRoberts.com
Sat, 26 Jan 2002 01:49:27 -0800


On Fri, 25 Jan 2002 18:27:41 -0800 (PST), you wrote:

>On Fri, 25 Jan 2002, James Roberts wrote:
>
>> I have a file, a text file, that has 15 or so lines of text, each line
>> ending in hard-return (Windows).  None of the lines are quoted, nor
>> are they delimited by comma's, or anything else.
>>=20
>> When I execute, in Komodo, a script that goes:
>>=20
>> list =3D open("list")
>> s =3D list.read()
>> print s
>>=20
>> ... I get the entire contents of the file printed out, just as it was
>> in the source file.  This I expect.  But, if I do the following:
>>=20
>> list =3D open("list")
>> s =3D list.readlines()
>> print list
>        ^^^^
>
>
>You probably mean:
>
>###
>print s
>###
>
>for the second example.  To avoid typos like that, you may want to =
change
>the name of your variables to something like 'list_file' so that there's
>less of a temptation to write "print list"... *grin*
>
>
>
>> ... then, all I get is several of the lines from the source file. =20
>> The lines do output as a list, with the lines of the source presented
>> as strings, with newlines at the end of each of the source lines, but
>> the ouput is only a few of the lines from the source.
>
>
>This is very odd!  You should be getting the whole file as a list of
>lines, and not just a partial list.  Where does it cut off?  Perhaps
>there's a strange character in there that Komodo is interpreting as a
>wacky character.  I don't believe that Komodo should be doing that =
though.
>
>If you can show us the text file that you're using, one of us at Tutor =
can
>see if we can duplicate the error.
>
>
>Good luck to you.
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

Danny,=20

I just figured out what was happening.   When viewing the output, in
Komodo, there is a scroll bar at the bottom.  I was sliding the
slide-bar all the way to the right, thinking that that is where the
line ends.  That is usually what happens in other programs.  However
with Komodo, sliding the horizontal scroll bar at the bottom of the
screen all the way to the right does not show you the end of the line.
You have to then use the right arrow on the scroll bar line, even
after the bar is all the way to the right, in order  to see the rest
of the output.  I found this out by "copying" the data to show it in
this message to demonstrate the problem I was having.  It was then
that I saw all the data.

In my view, this is a bug, in the sense that one would expect that
sliding the scroll bar all the way to the right should show you all
the data.

Thanks for the tip regarding naming variables.  I am brand new to
Python, and I appreciate it.

-- Jim=20