June 10th, 2013, 11:48 AM
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:
If you would like to see more of the code please let me know
with open('file.txt') as x:
head1 = x.readline('APS5000')
linenumber = 3
if not APU == head1:
for line in x.readline(linenumber):
linenumber += 1
if x.readline(linenumber) is ('====================================================')
linenumber = 14
June 10th, 2013, 12:06 PM
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.