Oct-10-2016, 07:32 PM
Sure, here's a simple example:
So have the login function calculate and return the value of logged_in. I would then pass that in to the set_user function as a parameter. That's generally the way you want to do things: if a variable is needed inside a function, pass it as a parameter. If a variable inside the function is needed outside, return it from the function. This avoids scope problems, makes things easier to understand, and makes things easier to debug.
def square(n): return n ** 2 four = square(2)Now the four variable has the value returned by the square function.
So have the login function calculate and return the value of logged_in. I would then pass that in to the set_user function as a parameter. That's generally the way you want to do things: if a variable is needed inside a function, pass it as a parameter. If a variable inside the function is needed outside, return it from the function. This avoids scope problems, makes things easier to understand, and makes things easier to debug.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures