title: Return int or string from C++ function exposed to Python
body: <p>Using Boost Python, is it possible for a C++ function exposed to python to return either an integer or a string (or other type) depending on the <em>value</em> of the single argument passed in?</p>
  
  <p>So in Python I want to do this:</p>
  
  <pre><code>from my_module import get_property_value     
  
  # get an integer property value
  i = get_property_value("some_int_property")
  
  # get a string 
  s = get_property_value("some_string_property")
  </code></pre>
  
  <p>C++ pseudo code (obviously won't it work like this, but you get the idea)</p>
  
  <pre><code>???? getPropertyValue(const char* propertyName)
  {
    Property *p = getProperty(propertyName);
    switch(p-&gt;type)
    {
      case INTEGER: return p-&gt;as_int();
      case STRING: return p-&gt;as_string();
      ...
    }
  }
  
  
  BOOST_PYTHON_MODULE(my_module)
  {
    boost::python::def("get_property_value", &amp;getPropertyValue);
  }
  </code></pre>
  
  <p>If it makes any difference, I'm using Boost 1.48 with Python 3.2.</p>