Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is parameter name in PyArg_UnpackTuple (python c api) for?

Tags:

python

c

This documentation http://docs.python.org/2/c-api/arg.html#PyArg_UnpackTuple describes all the parameters of function, except for const char *name.

What is this parameter for? What should I put there and why?

like image 508
Petr Avatar asked Feb 20 '14 12:02

Petr


People also ask

How do you convert strings to C in Python?

foo("string") passes a Python str object to a C function which will later assign the string to char *c_ptr .

What is argument in Python?

The terms parameter and argument can be used for the same thing: information that are passed into a function. From a function's perspective: A parameter is the variable listed inside the parentheses in the function definition. An argument is the value that are sent to the function when it is called.

What is PyObject in C?

A PyObject is in fact just a Python object at the C level. And since integers in Python are objects, they are also PyObject s. It doesn't matter whether it was written in Python or in C, it is a PyObject at the C level regardless.

What is PyEval_EvalFrameEx?

Almost the entire Python interpreter can be summarized into one C-level function: PyEval_EvalFrameEx. This function is the interpreter loop. Consisting of 3k lines of code, its job is to evaluate a frame, or in other words, run it.


1 Answers

According to the Python source (Python/getargs.c), the name argument is used when raising exceptions. So it could be the name of the function/method in which you use PyArg_UnpackTuple.

like image 60
geertjanvdk Avatar answered Oct 07 '22 23:10

geertjanvdk