def insert_into_file(fileobj, data, start, end):
 buffer = StringIO()
 fileobj.seek(end)
 copyfileobj(fileobj, buffer, (-1))
 buffer.flush()
 buffer.seek(0)
 fileobj.seek(start)
 fileobj.write(data)
 fileobj.flush()
 fileobj.truncate()
 delta = (fileobj.tell() - end)
 copyfileobj(buffer, fileobj, (-1))
 fileobj.flush()
 buffer.close()
 return delta

def insert_into_file ( fileobj , data , start , end ) : buffer = StringIO ( ) fileobj . seek ( end ) copyfileobj ( fileobj , buffer , ( - 1 ) ) buffer . flush ( ) buffer . seek ( 0 ) fileobj . seek ( start ) fileobj . write ( data ) fileobj . flush ( ) fileobj . truncate ( ) delta = ( fileobj . tell ( ) - end ) copyfileobj ( buffer , fileobj , ( - 1 ) ) fileobj . flush ( ) buffer . close ( ) return delta
insert data into fileobj at position c{start} .