Print random number of lines after read a file
<p>I am writing a thread-enabled python program which can read a file and send, but is there any ways to let the program read and send N numbers of line at a time?</p>

<pre><code>from random import randint
import sys
import threading
import time

def function():
    fo = open("1.txt", "r")
    print "Name of the file: ", fo.name

    while True:
        line = fo.readlines()
        for lines in line:
            print(lines)
            fo.seek(0, 0)
            time.sleep(randint(1,3))

game = threading.Thread(target=function)  
game.start()
</code></pre>

<p>The following python code only can let me send one line at a time, and then rewind. </p>

<p>something like this?</p>

<pre><code>from random import randint
import sys
import threading
import time

def function():
    fo = open("1.txt", "r")
    print "Name of the file: ", fo.name
    lines = fo.readlines()
    while lines:
        toSend = ""
        for i in range(0,random.randint(x,y)): #plug your range in
            toSend += lines.pop(0)
        print(toSend)

game = threading.Thread(target=function)  
game.start()
</code></pre>

python python-2.7 python-3.x