catch argc-argv

mg mg.mailing-list at laposte.net
Mon Jun 20 03:15:50 EDT 2005


Wolfram Kraus wrote:

>mg wrote:
>  
>
>>Hello,
>>
>>I am writting bindings for a FEM application. In  one of my function 
>>'initModulename', called when the module is imported, I would like to 
>>get the argc and argv arguments used in the main function of Python.
>>So, my question is: does the Python API containe fonctions like 
>>'get_argc()' and 'get_argv()' ?
>>
>>Thanks,
>>
>>
>>
>>    
>>
>Use sys.argv:
>http://python.org/doc/2.4.1/lib/module-sys.html
>
>HTH,
>Wolfram
>  
>
I know this module and this function. But, I search the same function in 
the C-API because a would like to know these variables directly in my 
bindings written in C++.

As an example, I try to create the following fonction :

PyMODINIT_FUNC initMyModule( void )
{
    int argc = Py_GetArgc() ; // I don't know if this function exist : I 
would like to know...
    char** argv = Py_GetArgv() ; // I don't know if this function exist 
: I would like to know...

    myfunction( argc, argv ) ;

   PyObject* module = Py_InitModule3( "MyModule", 0, "module of my FEM 
application" ) ;
}

Thanks to this C function written with the C-API of Python, I will 
create a new Python module and import it in the Python interpreter :

 >>> import MyModule





More information about the Python-list mailing list