I am trying to create a board for a game using list comprehension as shown in the code below.
class Game:
    row_num = 7
    column_num = 6
    board = [['[]' for i in range(row_num)] for x in range(column_num)]
However, when I run this I get: NameError: name 'row_num' is not defined. I've heard that list comprehension has their own namespace so I defined row_num as global as shown below.
class Game:
    global row_num
    row_num = 7
    column_num = 6
    board = [['[]' for i in range(row_num)] for x in range(column_num)]
This works fine, but my question is why doesn't python have a problem with the column_num variable? It is still in the same list comprehension so should have the same namespace as row_num?
 
    