Beginner question : skips every second line in file when using readline()

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Mon Oct 20 01:20:10 EDT 2003


On Sun, 19 Oct 2003 20:33:49 -0700, peter leonard wrote:
> while dataobject.readline() !="":

Reads the next line, compares it to the empty string, then throws it
away.

>         line = dataobject.readline()

Reads the next line and assigns it to the 'line' variable.

>         print line

Prints out the 'line' variable.

I think you can see where the problem is.

Possibly you want something like this:

    while( True ):
        line = dataobject.readline()
        if( line == "" ):
            break
        print line

-- 
 \        "Most people don't realize that large pieces of coral, which |
  `\       have been painted brown and attached to the skull by common |
_o__) wood screws, can make a child look like a deer."  -- Jack Handey |
Ben Finney <http://bignose.squidly.org/>




More information about the Python-list mailing list