title: python code returning nan when calling dll inside a for loop
body: <p>Now I have a very weird behaviour when trying to call a dll (compiled under Visual Studio 2008) in my python code.
  I imported the dll using ctypes module as follows:</p>
  
  <pre class="lang-html prettyprint-override"><code>import ctypes as C
  
  dll = C.cdll.LoadLibrary("C:\PyRates\\pyrateslibdll.dll")
  </code></pre>
  
  
  
  <p>if I call one of the functions of the dll in just one code line everything works fine, but if I call the same function inside a for loop I get nans even if code it's doing the same stuff. 
  For example:
  </p>
  
  <pre><code>ans = {}
  for i in [1,2]:
     ans[i] = dll.myfunc(i)
  </code></pre>
  
  
  
  <p>returns:
  </p>
  
  <pre><code>ans[i] = nan
  </code></pre>
  
  <p>
  on some of its calls, whereas if I execute this code:
  </p>
  
  <pre><code> i = 1
   ans[i] = dll.myfunc(i)
   i = 2
   ans[i] = dll.myfunc(i)
  </code></pre>
  
  <p>
  I get what I should expect.</p>
  
  <p>Has anyone had the same behaviour?
  Thanks for your help
  I'm using Python 2.7 in windows 64bit but dll and python are running in 32bit.</p>