Re: [C++-sig] Abstract class instances to-python conversion

2011-08-02 Thread Valentin Perrelle
In cpp it would be like: import('sys').attr('modules')['mymodule'].del() Thank you, it worked. However, I believe it would only remove one module, not any other module imported. I tried to clear the dictionnary, which worked in Python, i didn't achieve to reproduce this in c++. Anyway, this w

Re: [C++-sig] Abstract class instances to-python conversion

2011-08-01 Thread Simon Warg
You can remove one reference from the sys module: Import sys del sys.modules['mymodule'] In cpp it would be like: import('sys').attr('modules')['mymodule'].del() I can give you my code later. Don't have it here! // Simon On 1 aug 2011, at 13:38, Valentin Perrelle wrote: > Le 01/08/2011 13:19

Re: [C++-sig] Abstract class instances to-python conversion

2011-08-01 Thread Valentin Perrelle
Le 01/08/2011 13:19, Simon Warg a écrit : In My program I need to unload modules as well. What I do is remove all references to the particular module and it will be unloaded. It seems i didn't achieve to do that. There should be some references i can't remove, i don't know why yet. Are you

Re: [C++-sig] Abstract class instances to-python conversion

2011-08-01 Thread Simon Warg
In My program I need to unload modules as well. What I do is remove all references to the particular module and it will be unloaded. Are you using boost python for python 2 or 3? If it's the latter it is safe to use Py_Finalize()! I use it myself! // Simon On 1 aug 2011, at 12:58, Valentin Per

Re: [C++-sig] Abstract class instances to-python conversion

2011-08-01 Thread Valentin Perrelle
You could use the reload() function in python 2.7 or imp.reload() in python 3. It takes a module object as argument. Thanks. However it wouldn't reset to the initial state in the general case. All modules needs to be unloaded. I don't know a safe way to it yet. I'm just sure i want to do it i

Re: [C++-sig] Abstract class instances to-python conversion

2011-08-01 Thread Simon Warg
You could use the reload() function in python 2.7 or imp.reload() in python 3. It takes a module object as argument. // Simon On 1 aug 2011, at 12:00, Valentin Perrelle wrote: > >> All of that sounds sounds. But at what point were you trying to register a >> to-python converter? It sounded

Re: [C++-sig] Abstract class instances to-python conversion

2011-08-01 Thread Valentin Perrelle
All of that sounds sounds. But at what point were you trying to register a to-python converter? It sounded like you were trying to do that before importing the module, and since a to-python converter is by definition C++, I didn't understand how you could do it in a Python script before imp

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-31 Thread Jim Bosch
On 07/31/2011 12:52 AM, Valentin Perrelle wrote: Le 31/07/2011 07:38, Jim Bosch a écrit : I guess I don't really understand how your program flow is supposed to work - how did you plan to invoke C++ code from Python before importing your Boost.Python module? Usually the natural place to register

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-31 Thread Valentin Perrelle
Le 31/07/2011 07:38, Jim Bosch a écrit : I guess I don't really understand how your program flow is supposed to work - how did you plan to invoke C++ code from Python before importing your Boost.Python module? Usually the natural place to register converters is during module import after you'v

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-30 Thread Jim Bosch
On 07/30/2011 03:18 PM, Valentin Perrelle wrote: Thanks to you, I know understand some points i couldn't catch reading the manual 3-4 times. I'm now able to fix the current problem by importing my module before assigning the variable 'keyboard'. Which leads me to another question : is there a way

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-30 Thread Valentin Perrelle
Thank you for your answer. > Why do you think you can't have noncopyable? I understood it prevents the registration of converters for the class. I just read the manual again and now i understand it only remove converter which copy instances, i.e. conversion of values. Anyhow, I'd recommend

Re: [C++-sig] Abstract class instances to-python conversion

2011-07-30 Thread Jim Bosch
On 07/30/2011 01:15 PM, Valentin Perrelle wrote: Hi, I'm currently embedding and extending Python using Boost.Python. I'm trying to expose some c++ library (OIS) classes to my Python scripts. This library mainly exposes abstract classes since the actual implementation are derived classes special