| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -439,16 +439,24 @@ API Functions | |||
| 439 | 439 | .. versionadded:: 3.2 | |
| 440 | 440 | ||
| 441 | 441 | ||
| 442 | - .. XXX deprecated, will be removed | ||
| 443 | 442 | .. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...) | |
| 444 | 443 | ||
| 445 | - Function used to deconstruct the argument lists of "old-style" functions --- | ||
| 446 | - these are functions which use the :const:`METH_OLDARGS` parameter parsing | ||
| 447 | - method, which has been removed in Python 3. This is not recommended for use | ||
| 448 | - in parameter parsing in new code, and most code in the standard interpreter | ||
| 449 | - has been modified to no longer use this for that purpose. It does remain a | ||
| 450 | - convenient way to decompose other tuples, however, and may continue to be | ||
| 451 | - used for that purpose. | ||
| 444 | + Parse the parameter of a function that takes a single positional parameter | ||
| 445 | + into a local variable. Returns true on success; on failure, it returns | ||
| 446 | + false and raises the appropriate exception. | ||
| 447 | + | ||
| 448 | + Example:: | ||
| 449 | + | ||
| 450 | + // Function using METH_O calling convention | ||
| 451 | + static PyObject* | ||
| 452 | + my_function(PyObject *module, PyObject *arg) | ||
| 453 | + { | ||
| 454 | + int value; | ||
| 455 | + if (!PyArg_Parse(arg, "i:my_function", &value)) { | ||
| 456 | + return NULL; | ||
| 457 | + } | ||
| 458 | + // ... use value ... | ||
| 459 | + } | ||
| 452 | 460 | ||
| 453 | 461 | ||
| 454 | 462 | .. c:function:: int PyArg_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, ...) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments