Importing variables from another file in Python

Viewed 38510

I have declared a few variables and initialised them with some value in variables.py:

flag = 0
j = 1

I want to use those values in another file main_file.py:

import variables
if(flag == 0) :
   j = j+1

However I get the following error,

NameError: name 'flag' is not defined

How can i solve this problem?

3 Answers
Related