title: Using builtins to store global variables across modules
body: <p>I have a Jupyter notebook which I want to use simply to run a bunch of functions that are defined in a python 'helper' file. The notebook does however have a few variables which the user can change (so they are like constants I suppose). I want these variables to be accessible from the helper file too. I would prefer not to have to pass these variables to each function call in the notebook.</p>
  
  <p>I have found that the following works when defining these variables in the notebook:</p>
  
  <pre><code>import builtins
  
  builtins.my_variable = my_value
  </code></pre>
  
  <p>The variable 'my_variable' can now be used in both the Jupyter notebook and the helper file. </p>
  
  <p>NOTE: After defining the variable in this way, if I type <code>help(builtins)</code> in the notebook and scroll all the way to the bottom, under the 'DATA' section I find my variable listed.</p>
  
  <p>Another thing that works:</p>
  
  <pre><code>import helper
  helper.my_variable = my_value
  </code></pre>
  
  <p>Could someone explain why/how these things works, if there are any problems with using them and if so, potentially a better way of doing it?</p>