Hi all, I have been learning to write extension modules using the C API that python provides, and have hit a minor roadblock that is turning out to be major headache. My project essentially is organized as follows,
foo | --------------------------------- | | | bar _foo baz _foo basically does some init stuff, nothing much. Thats where the problem starts. The "handler" variable which is initialized in _foo isn't visible to others. One solution that worked was calling the initializing function in each of the module's PyMODINIT_FUNC. Debugging through the interpreter I found out the it loads all the .so's and executes PyMODINIT_FUNCs. But by doing so, the routine to initialize the handle gets executed three times, something which i find to be sort of unclean. The definition of the variable is included in a header and the sources of the other modules include this master header, So I do have that variable in scope, but its not initialized. _foo does the job of declaring that variable. I did my share of RTFM and found CObjects as a potential alternative. But I feel its use rather complicated for a single variable that goes out of scope. Is there any other way to solve this, or is my approach itself borked =(?, What am I missing? Thanks for your help -- Sudharshan S http://www.sudharsh.wordpress.com -- http://mail.python.org/mailman/listinfo/python-list