[C++-sig] call python iterable (handle StopIteration?)
Stefan Seefeld
seefeld at sympatico.ca
Tue Jul 17 15:53:35 CEST 2007
Neal Becker wrote:
> I want to call a python iterable from c++. Can I do this?
> while (true) {
> T n = extract<T> (o.attr ("next")());
> tmp.push_back (n);
> }
>
> How do I (can I?) catch the StopIteration exception?
Assuming boost.python does not have special provisions for
any particular exception type you'd need to catch error_already_set
and then query (using the python C API) the exact exception type in
order to break out of the loop.
It would be worthwhile thinking about better handling of this (as
well as adding more exception-related APIs) for 1.35... </wink>
Regards,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list