Revision 1 as of 2002-09-25 19:57:58

Clear message

extractor interface which can be used to extract C++ types from Python objects.

We have discussed two main use cases for extractions

1. In user code which needs to retrieve C++ objects from their corresponding Python objects:

  1. Getting value:
    •     void f(object x)
          {
              int y = extract<int>(x); // retrieve an int from x
          }
  2. Users may also want to explicitly check for convertibility:
    •     int g(object x)
          {
              extractor<int> get_int(x);
              if (get_int)
                  return get_int();
              else
                  return 0;
          }

2. In the implementation of sequence from_python converters (e.g. Python tuple/list -> std::vector)

Unable to edit the page? See the FrontPage for instructions.