Hey all, is it possible to call a function value instead of calling the whole function?As, if i call the whole function, it will run unnecessarily which i do not want. For example:
def main():
# Inputing the x-value for the first start point of the line
start_point_x_1()
# Inputing the x-value for the 2nd end point of the line
end_point_x_2()
# The first output point calculated and printed
first_calculated_point()
def start_point_x_1():
return raw_input("Enter the x- value for the 1st " +
"start point for the line.\n")
def end_point_x_2():
return raw_input("Enter the x- value for the 2nd " +
"end point for the line.\n")
def first_calculated_point():
x0 = int(start_point_x_1())
a = int(end_point_x_2()) - int(start_point_x_1())
lamda_0 = 0
x = x0 + (lamda_0)*a
main()
The code above works but when i reach the function first_calculated_point
and when i calculate x0
, the function start_point_x_1()
runs again.I tried storing the function like ' for example x1 = raw_input("Enter the x- value for the 1st " + "start point for the line.\n")
under the function start_point_x_1()
but when i call the variable x1
at x0 = x1
, they said x1
is not defined. Is there any way to store the value of the function and call it instead of calling the whole function?