Everything you’ve done is right except when using the variables.
In your main_file.py file:
if(variables.flag == 0) : variables.j = variables.j + 1
(Or)
Use the following header :
from variables import *
(Or)
from variables import flag, j
Replace all the references of flag and j (or any other variable you want to use from that file) with the prefix ‘variables.’
Since this is just a copy of the variable, the values in the variables.py won’t get affected if you modify them in main_file.py
Related Posts:
- Python: ‘ModuleNotFoundError’ when trying to import module from imported package
- Relative imports – ModuleNotFoundError: No module named x
- Relative imports in Python 3
- Is “from matplotlib import pyplot as plt” == “import matplotlib.pyplot as plt”?
- Python error “ImportError: No module named”
- Python error “ImportError: No module named”
- ImportError: No module named requests
- Importing modules from parent folder
- `from … import` vs `import .` [duplicate]
- Importing modules from parent folder
- Importing files from different folder
- Importing files from different folder
- ImportError: Cannot import name X
- How to import the class within the same directory or sub directory?
- How do I unload (reload) a Python module?
- How to import the class within the same directory or sub directory?
- How to import other Python files?
- django import error – No module named core.management
- How to fix “Attempted relative import in non-package” even with __init__.py
- ImportError: libSM.so.6: cannot open shared object file: No such file or directory
- How to fix “Attempted relative import in non-package” even with __init__.py
- How to import a module given the full path?
- Why does using from __future__ import print_function breaks Python2-style print?
- ImportError: No module named ‘cv2’ Python3
- NameError: name ‘requests’ is not defined
- How to load all modules in a folder?
- Import a file from a subdirectory?
- Installing lxml module in python
- ModuleNotFoundError: What does it mean __main__ is not a package?
- Import file from parent directory?
- How do I copy a file in Python?
- Pig Latin Translator
- Understanding slice notation
- How do you round UP a number?
- How to open a file using the open with statement
- How to comment out a block of code in Python [duplicate]
- Using “with open() as file” method, how to write more than once? [duplicate]
- How do I get a substring of a string in Python?
- Python return statement error ” ‘return’ outside function”
- ImportError: No module named pandas
- IndexError: too many indices for array
- TypeError: cannot unpack non-iterable NoneType object
- Where does pip install its packages?
- Python inline if statement
- if/else in a list comprehension
- data type not understood
- How to read a text file into a string variable and strip newlines?
- What does hash do in python?
- How to copy a dictionary and only edit the copy
- Creating a static class with no instances
- How to avoid “RuntimeError: dictionary changed size during iteration” error?
- if/else in a list comprehension
- Could not find a version that satisfies the requirement tensorflow
- how do you check your django version in cmd
- Pandas, merging two dataframes on multiple columns, and multiplying result
- Are dictionaries ordered in Python 3.6+?
- How to customize a scatter matrix to see all titles?
- What is the problem with shadowing names defined in outer scopes?
- TypeError: write() argument must be str, not bytes (Python 3 vs Python 2 )
- How to clear the interpreter console?
- How to make a class JSON serializable
- What does the ‘b’ character do in front of a string literal?
- Forbidden (403) CSRF verification failed. Request aborted. Even using the {% csrf_token %}
- Flask ImportError: No Module Named Flask
- ModuleNotFoundError: No module named ‘MySQLdb’
- How to change dataframe column names in pyspark?
- Normalize data in pandas
- Unresolved reference issue in PyCharm
- How to use 2to3 properly for python?
- Is there a way to return literally nothing in python?
- Is there a built-in function to print all the current properties and values of an object?
- How to troubleshoot an “AttributeError: __exit__” in multiproccesing in Python?
- TypeError : Unhashable type
- Read PDF in Python and convert to text in PDF
- Pytesseract : “TesseractNotFound Error: tesseract is not installed or it’s not in your path”, how do I fix this?
- Pointers in Python?
- Django – no such table exception
- ImportError: No module named ‘google’
- ‘int’ object has no attribute ‘append’
- What does the “x for x in” syntax mean?
- Numpy extract submatrix
- How to check if a column exists in Pandas
- How to get line count of a large file cheaply in Python?
- Getting
with Python http requests instead of INT - What does “Symbol not found / Expected in: flat namespace” actually mean?
- When to use ‘raise NotImplementedError’?
- TypeError: coercing to Unicode: need string or buffer, list found
- environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON
- Find the unique values in a column and then sort them
- Adding +1 to a variable inside a function
- Difference between data type ‘datetime64[ns]’ and ‘
- Merging two DataFrames
- CSV new-line character seen in unquoted field error
- Creating a truth table for any expression in Python
- Anaconda – UnsatisfiableError: The following specifications were found to be in conflict
- spyder – clear variable explorer along with variables from memory
- How to change python version in Anaconda?
- TypeError: ManyRelatedManager object is not iterable
- vectorize conditional assignment in pandas dataframe
- Using print() (the function version) in Python2.x