title: Cython direct access to Global Variable
body: <p>How can I access a global variable declared with Cython, without using a accessor function?</p>
  
  <p>I tried with following example:</p>
  
  <p><strong>pyfunktionen_a.pyx</strong></p>
  
  <pre><code>import numpy as np
  
  cdef extern from "funktionen_a.h":
      cdef void setValue(int value_to_set)
      cdef int readValue()
      cdef int value
  
  def pysetValue (_value):
      setValue(_value)
  
  def pyreadValue():
      print readValue()
  
  def manipulateValue(value_to_set):
      value = value_to_set
  </code></pre>
  
  <p><strong>funktionen_a.c</strong></p>
  
  <pre><code>#include "funktionen_a.h"
  
  
  void setValue(int value_to_set){
  
      value = value_to_set;
  }
  
  int readValue(){
      return value;
  }
  </code></pre>
  
  <p><strong>funktionen_a.h</strong></p>
  
  <pre><code>#include &lt;Python.h&gt;
  #include &lt;stdio.h&gt;
  
  
  void setValue(int value_to_set);
  int readValue();
  
  int value;
  </code></pre>
  
  <p>And with this function I control the whole thing:</p>
  
  <p><strong>control.py</strong></p>
  
  <pre><code>import pyfunktionen_a
  
  pyfunktionen_a.pysetValue(8)
  pyfunktionen_a.pyreadValue()
  
  pyfunktionen_a.manipulateValue(5)
  pyfunktionen_a.pyreadValue()
  </code></pre>
  
  <p>What results i <strong>expected</strong>:</p>
  
  <pre><code>&gt;&gt;    8
  &gt;&gt;    5
  </code></pre>
  
  <p>But what results i <strong>get</strong>:</p>
  
  <pre><code>&gt;&gt;    8
  &gt;&gt;    8
  </code></pre>