Hello, can I draw a line segment by giving it the starting and ending coordinates through a Python script

Just add a coordinate to the nodes list:

coordinates = [(10, 10), (100, 100), (10, 40)]

my_path = GSPath()

my_path.nodes = [GSNode(coordinate) for coordinate in coordinates]

Layer.shapes.append(my_path)

Add path.closed = True if you want the path to be closed.