title: How do I pass an Objective C instance into a PyObjC Python function when using PyRun_File()/PyObject_CallFunction()?
body: <p>I'm embedding Python in an Objective C application using PyObjC, setting the Python environment up by hand on the ObjC side (i.e. not using py2app).  I'm starting the Python in a separate thread (on the ObjC side) with a call to <code>PyRun_File()</code>, and then one to <code>PyObject_CallFunction()</code> to start it doing something (specifically update some menus, register and handle menu callbacks).  The Python function starts the run loop for the secondary thread and the callback class instance hangs around.  All of this works.  I can pass basic data such as strings to the initial Python function without problem and menu actions work as I'd like.  </p>
  
  <p>I'd like to provide a pre-instantiated delegate instance to the Python function for ease of configuration (from the point of view of the Objective C developer).  How do I pass an Objective C instance (my delegate) to the Python function?  Is it possible?  Are there bridge functions I'm missing?  Do I need to create a suitably configured PyObject by hand?  What sort of conversion should I do on the Python side to ensure the <code>delegate.methods()</code> are usable from Python and proxying works as it should?  Are there any memory-management issues I should be aware of (on either side of the bridge)?</p>
  
  <p>I'm using Python 2.7, PyObjC 2.5 and targeting OSX 10.6.  Happy to consider changing any of those if the solution specifically demands it. TIA.</p>