Finally figured out the code to my question.. !! Thus answering it... Thank you for your inputs..
Ipath = raw_input("Enter the input file :- ")
Opath = raw_input("Enter the output directory :- ")
Ipath = Ipath.replace("\\", "/") # Python requirement for paths
Opath = Opath.replace("\\", "/")
copyfile(str(Ipath) + ".prj", str(Opath) + "/" + "Out_Lines" + ".prj") # Copying projection file
sf = shapefile.Reader(str('Input Path'))
shapes = sf.shapes()
Box = shapes[0].bbox
Spc = input("Enter the grid spacing :- ") # Grid Spacing read
x_min = Box[0] # Save the coordinates of the right-bottom, left-top bounding box
y_min = Box[1]
x_max = Box[2]
y_max = Box[3]
A_bbox = [x_min, y_min] # First assignment of coordinates
B_bbox = [x_max, y_max]
C_bbox = [x_min, y_max]
D_bbox = [x_max, y_min]
w = shapefile.Writer(shapefile.POLYLINE) # Shapefile writer
w.line(parts = [[A_bbox, C_bbox]])
w.field('Path number', 'C', '50')
w.record(str(1)) # Writes the first line, that is the left 'side' of the bounding box
# Increasing the X coordinate to generate a line at a specified spacing
i = 2
while (A_bbox[0] <= x_max):
A_bbox = [A_bbox[0] + Spc, A_bbox[1]]
C_bbox = [C_bbox[0] + Spc, C_bbox[1]]
w.line(parts = [[A_bbox, C_bbox]])
w.record(str(i))
i = i+1
w.save(str(Opath) + "/" + "Out_Lines")
This saves the result in a shapefile.
As a continuation to the above mentioned question, the solution of the problem is available at Clipping Line shapefiles within extent of Polygon shape. I think that this set of questions can now be considered answered and closed.
Thank you all for your assistance.