translating C++ exceptions to python

harold fellermann harold.fellermann at upf.edu
Mon Jun 13 18:30:19 EDT 2005


On 13.06.2005, at 13:23, calin.hanchevici at gmail.com wrote:

> Hi all,
>
> I have a C++ library I call from python. The problem is I have c++
> exceptions that i want to be translated to python. I want to be able to
> do stuff like:
> try:
>     my_cpp_function()
> except cpp_exception_1:
>     do_stuff
> except cpp_exception_2:
>     do_other_stuff
>
> any ideas how can i do the translation?

If you do not already use it, have a look at
http://www.boost.org/libs/python/ a C++ -- library to wrap the
Python C API, i.e. it helps you to extend Python in C++.
AFAIK it has fascilities to transform exceptions from one type
into the other.

- harold -

---
Everybody lies. but it does not matter, as no one listens.
---




More information about the Python-list mailing list