Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to acess global variables within function python

#A global variable can be accessed from any function or method.
#However, we must declare that we are using the global version and not the local one.
#To do this, at the start of your function/method write "global" and then the name of the variable.
#Example:
myVariable = 1

def myFunction():
  global myVariable
  print(myVariable)

myFunction() 
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #acess #global #variables #function #python
ADD COMMENT
Topic
Name
6+7 =