title: Robot Framework: access Robot's global variables from Python library code?
body: <p>I have some settings-type global vars that I'd like to be able to access from Python code. For example:</p>
  
  <pre><code>pybot --variable RESULTS_PATH:/wherever/this/points test.txt
  </code></pre>
  
  <p>Now, my module <code>logger.py</code> file needs to know the results_path to set up properly.</p>
  
  <p>I know that I can initialize the logger with a variable, like</p>
  
  <pre><code>***Settings***
  Library  logger  ${RESULTS_PATH}
  </code></pre>
  
  <p>And then in logger I'll be passed results_path:</p>
  
  <pre><code> def __init__(self, results_path):
     # Whatever
  </code></pre>
  
  <p>However the problem with doing it this way for me is that I want to access and use the logger from both Python code and within test cases. So if I set it up this way, if I want to use the logger from Python code I run into the same problem of needing results_path to initialize the logger properly.</p>
  
  <p>Are there any functions in the robot framework library that would allow me to grab the value of ${RESULTS_PATH} from Python code? What is the proper way to do something like this?</p>
  
  <p>Right now, my workaround for the issue is to set RESULTS_PATH as an environment variable. So I have something like:</p>
  
  <p>Run like:</p>
  
  <pre><code>RESULTS_PATH=/wherever/this/points pybot test.txt
  </code></pre>
  
  <h3>File <code>test.txt</code>:</h3>
  
  <pre><code>***Settings***
  Library  logger
  ...
  </code></pre>
  
  <h3>File <code>logger.py</code>:</h3>
  
  <pre><code>results_path = os.environ["RESULTS_PATH"]
  # Other set up stuff
  </code></pre>