I am trying to open specific lines of multiple files and return the lines of each file. My solution is taking quite time-consuming. do you have any suggestion?
func.filename: the name of the given file
func.start_line: the starting point in the given file
func.endline: finishing point in the given file   
def method_open(func):
    try:
        body = open(func.filename).readlines()[func.start_line:
                                               func.end_line]
    except IOError:
        body = []
        stderr.write("\nCouldn't open the referenced method inside {0}".
                     format(func.filename))
        stderr.flush()
    return body
Have in mind that sometimes the opening file func.filename can be the same but unfortunately, this is not the case most of the time.
 
    