What is correct way to use data from functions in Python scripts?
Using print, like:
var1 = 'This is var1'
def func1():
print(var1)
func1()
Or - with return:
var1 = 'This is var1'
def func1():
return var1
print(func1())
Both give same result:
$ ./func_var_print_return.py
This is var1
print func1()vsprint func2(). (where your 2nd func1 Is func2!) But in all honestly in your example it doesn't really matter, because var1 is a "global" variable and stays the same regardless of the functions involved! - Don Question