[C++-sig] registering the same type converter in different modules with Boost.Python

2010-08-29 Thread Changsheng Jiang
Hi, list

I have to convert std::pair to python tuple in different modules
independently. And these modules may be used concurrently, importing the
second module will report an warning like "std::pair has been already
registered".

How to fixed the warning and registered the same type in different modules
correctly?

thanks.

  Changsheng Jiang
___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig

Re: [C++-sig] registering the same type converter in different modules with Boost.Python

2010-08-29 Thread Ralf W. Grosse-Kunstleve
> I have to convert std::pair to python tuple in different modules  
>independently.
> And these modules may be used concurrently, importing the  second module
> will report an warning like "std::pair has been already  registered".

A simple and clean approach is to have another basic module that defines the 
std::pair conversions,
and import that from the two modules you have already.
I never import extensions directly, but wrap each in a (possibly trivial) 
Python 
module; this has
many advantages unrelated to your original question. Then you can simply write:

module1.py
  import basic # e.g. with std::pair converters
  from module1_ext import *

similar for module2.py.

Ralf___
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig