#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Readline function using a string in place of an integer


    I'm trying to write a python script that will initialize an automated test based on a number of parameters that are passed during execution. One of the parameters is used as device selection control in a text file that is being used in a readline() call in place of an integer.

    How do I make the following work w/o causing an error during use:

    Code:
     with open('file.txt') as x:
             head1 = x.readline('APS5000[]')
             linenumber = 3
             if not APU == head1:
                    for line in x.readline(linenumber):
                        print line
                        linenumber += 1
                        if x.readline(linenumber) is ('====================================================')
                              linenumber = 14
                        break
    If you would like to see more of the code please let me know
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2012
    Location
    39N 104.28W
    Posts
    158
    Rep Power
    3
    The argument to file.readline() is the maximum number of bytes, not the line number. 'file' is an iterator and .readline() processes the next iteration.

IMN logo majestic logo threadwatch logo seochat tools logo