I'm currently writing a set of container classes using Boost.Python to wrap
an existing C++ library. Progress has been very good - not even two days
and I've wrapped all the existing C++ methods (at least 100). But of course
a library designed for C++ is not a library designed for Python. Job 2 is
to make it more Pythonic.
The current problem is implementing slicing in the __getitem__, __setitem__
and __delitem__ methods. These are already working with single keys. To
handle slicing, I need to identify in the key object is a slice object.
This is the sticking point right now.
I can access the type of the object using p.attr ("__class__") - but how do
I get access to the slice type object from __builtins__ in order to compare?
I could probably use a workaround such as extracting and checking a string
representation from p.attr ("__class__").str (), but it seems to me that
the ability to import symbols from another module (whether __builtins__ or
some other Python or extension module).
This could reduce to the ability to convert a PyObject* to an object
instance - even more useful for using any C API functions that don't have a
Boost.Python wrapper - but there seems to be no obvious way to do this.
In addition, my containers are currently declared as follows...
class_