title: C++ and Python- checking type of PyObject fails
body: <p>I'm a bit confused. I'm trying to do some C++ and Python integration, but it's less than straightforward. I'm not using Boost, because I couldn't get Boost::Python to compile properly. But that's another story.</p>
  
  <p>Currently, here's what I'm doing in C++:</p>
  
  <pre><code>//set everything up
  PyObject* py_main_module = PyImport_AddModule("__main__");
  PyObject* py_global_dict = PyModule_GetDict(py_main_module);
  PyObject* py_local_dict = PyDict_New();
  PyObject* py_return_value;
  
  PyRun_SimpleString(data.c_str()); //runs Python code, which defines functions
  
  //call a function defined by the python code
  py_return_value = PyRun_String("test()", Py_single_input, py_global_dict, py_local_dict);
  
  //attempt to check the type of the returned value
  if(py_return_value != NULL) {
      //this is the problem: all of these print 0
      cout &lt;&lt; PyList_Check(py_return_value) &lt;&lt; endl;
      cout &lt;&lt; PySet_Check(py_return_value) &lt;&lt; endl;
      cout &lt;&lt; PyFloat_Check(py_return_value) &lt;&lt; endl;
  } else {
      cout &lt;&lt; "IT WAS NULL?!" &lt;&lt; endl;
  }
  </code></pre>
  
  <p>The Python program (input to the C++ program as the string named "data"):</p>
  
  <pre><code>def test():
      derp = 1.234
      #derp = [1, 2, 3, 4]
      #derp = set([1, 2, 3, 4])
      return derp
  </code></pre>
  
  <p>Now, the problem is that the type checks aren't working. They all return 0, regardless of whether the Python function is returning a float, a list, or a set. What am I doing wrong?</p>
  
  <p>Bonus points if anyone can tell me why the call to PyRun_String prints the returned value in the console. It's really annoying.</p>