Introduction to the function list in the Python Module

Source: Internet
Author: User

If you encounter some incomprehensible questions about the Python module during the actual application process of the Python module, you can use our article to provide a relatively good answer to the Python module related questions, the following is an introduction to the specific content of the article. I hope you will gain some benefits.

Modules and functions use the PyImport_Import () function in Python/C APIs to import Python modules to C Programs. The PyImport_Import () function returns a module object. The function prototype is as follows.

 
 
  1. PyObject* PyImport_Import( PyObject *name)  

The parameter meanings are as follows. Name: name of the module to be imported. Using the PyObject_CallObject () and PyObject_CallFunction () functions in Python/C APIs, you can call the functions in the Python module in the C program. The parameter prototypes are as follows.

 
 
  1. PyObject* PyObject_CallObject( PyObject *callable_object, PyObject *args)  
  2. PyObject* PyObject_CallFunction( PyObject *callable, char *format, ...)  

For the PyObject_CallObject () function, the parameter meanings are as follows. Callable_object: The function object to be called. Args: list of parameters in the format of tuples. The parameter meanings of PyObject_CallFunction () are as follows. Callable_object: The function object to be called. Format: Specifies the parameter type. Parameters passed to the function.

Use the PyModule_GetDict () function in Python/c api to obtain the function list in the Python module. The PyModule_GetDict () function returns a dictionary. The keyword in the dictionary is the function name and the value is the call address of the function. The function prototype is as follows.

 
 
  1. PyObject* PyModule_GetDict( PyObject *module)   

The above is an introduction to the practical application of Python modules and functions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.