All Questions
3 questions
-1
votes
2
answers
801
views
How to decide if a global variable is used inside or outside a function in Python?
In Python variables that are created outside of a function are known as global variables. However to create a global variable inside a function (a local variable), you can use the global keyword.
My ...
3
votes
2
answers
1k
views
How to name variables that clash with functions?
As an example, in Python I have a lowest_prime_factor function which does it exactly what it says it does. Then, in another function, I need to call this function and store it. In another language ...
2
votes
1
answer
13k
views
Python: Faster to use global variable or pass as arguments to a function? [duplicate]
Hey so i was wondering which is the more efficient way, or better practice to do in this situation.
1,
def function():
global number
number += 2
Or 2,
def function(number):
return ...