I have the following code in python:
board = 0
def Board1():
global board
board = 1
def Board2():
global board
board = 2
def Board3(board):
board = 3
print board
def ReadBoard():
print board
I think the functions Board1 and Board2 should change the value of the global variable board. But here is what happens: When I call board it returns 0. If I call Board1, the global board value does not change, but if I call ReadBoard, it gives the value Board1 has assigned. For example (in python console):
>>> board
0
>>> Board1()
>>> board
0
>>> ReadBoard()
1
>>> Board3(board)
3
>>> board
0
>>> board = 4
>>> ReadBoard()
1
I could not understand why I cannot change the global variable globally and why am I reading the changed variable in the ReadBoard function.
from somemoduleididntmention import *, which you should never do and which is also your entire problem.