boost python & context manager/with statement

Does boost python support context management using the with statement? In my case I need to manage __enter__/__exit__ on the c++ side. Could not find any examples for this in the documentation. Any help appreciated. Best regards, Ta, Avi

on Sun Feb 12 2012, Avi Bahra <avibahra-AT-googlemail.com> wrote:
Does boost python support context management using the with statement? In my case I need to manage __enter__/__exit__ on the c++ side. Could not find any examples for this in the documentation.
Any help appreciated.
Best regards, Ta, Avi
There's no explicit support for it, no. Sorry, -- Dave Abrahams BoostPro Computing http://www.boostpro.com

From: Dave Abrahams <dave@boostpro.com>
To: boost-users@lists.boost.org Cc: cplusplus-sig@python.org Sent: Tuesday, February 28, 2012 10:06 PM Subject: Re: [Boost-users] boost python & context manager/with statement
on Sun Feb 12 2012, Avi Bahra <avibahra-AT-googlemail.com> wrote:
Does boost python support context management using the with statement? In my case I need to manage __enter__/__exit__ on the c++ side. Could not find any examples for this in the documentation.
Any help appreciated.
Best regards, Ta, Avi
There's no explicit support for it, no.
Sorry,
But I think you could implement it like this: class_<SomeClass>(...) .def("__enter__", &somefunc) .def("__exit__", &someotherfunc) ; Trigve
participants (3)
-
Avi Bahra
-
Dave Abrahams
-
Trigve Siver