title: Is is possible to return an object or value from a Python script to the hosting application?
body: <p>For example in Lua you can place the following line at the end of a script:</p>
  
  <pre><code>return &lt;some-value/object&gt;
  </code></pre>
  
  <p>The value/object that is returned can then be retrieved by the hosting application.</p>
  
  <p>I use this pattern so that scripts can represent factories for event handlers.  The script-based event handlers are then used to extend the application.  For example the hosting application runs a script called 'SomeEventHandler.lua' which defines and returns an object that is an event handler for 'SomeEvent' in your application.</p>
  
  <p>Can this be done in Python?  Or is there a better way to achieve this?</p>
  
  <p>More specifically I am embedding IronPython in my C# application and am looking for a way to instance these script-based event handlers which will allow the application to be extended using Python.</p>