summaryrefslogtreecommitdiffstats
path: root/Doc/howto
diff options
context:
space:
mode:
authorLarry Hastings <larry@hastings.org>2014-01-22 13:49:11 (GMT)
committerLarry Hastings <larry@hastings.org>2014-01-22 13:49:11 (GMT)
commit42d9e1b9f3ac02169336016d203b7ff78eb72882 (patch)
tree2a3ccab0ac292bbb8b24ec7fc2fa361a0396ebed /Doc/howto
parentd58831e6886ce457626448c6c2efd1f4cd05dd3a (diff)
downloadcpython-42d9e1b9f3ac02169336016d203b7ff78eb72882.zip
cpython-42d9e1b9f3ac02169336016d203b7ff78eb72882.tar.gz
cpython-42d9e1b9f3ac02169336016d203b7ff78eb72882.tar.bz2
Doc fixes for Argument Clinic.
Diffstat (limited to 'Doc/howto')
-rw-r--r--Doc/howto/clinic.rst24
1 files changed, 18 insertions, 6 deletions
diff --git a/Doc/howto/clinic.rst b/Doc/howto/clinic.rst
index 5ee6c3d..20477db 100644
--- a/Doc/howto/clinic.rst
+++ b/Doc/howto/clinic.rst
@@ -626,6 +626,15 @@ Optional groups are groups of arguments that must all be passed in together.
They can be to the left or the right of the required arguments. They
can *only* be used with positional-only parameters.
+.. note:: Optional groups are *only* intended for use when converting
+ functions that make multiple calls to :c:func:`PyArg_ParseTuple`!
+ Functions that use *any* other approach for parsing arguments
+ should *almost never* be converted to Argument Clinic using
+ optional groups. Functions using optional groups currently
+ cannot have accurate sigantures in Python, because Python just
+ doesn't understand the concept. Please avoid using optional
+ groups wherever possible.
+
To specify an optional group, add a ``[`` on a line by itself before
the parameters you wish to group together, and a ``]`` on a line by itself
after these parameters. As an example, here's how ``curses.window.addch``
@@ -1278,9 +1287,8 @@ a ``type`` argument to the object converter for ``METH_O``.
tp_new and tp_init functions
----------------------------------------------
-You can convert ``tp_new`` and ``tp_init``
-functions. Just name them ``__new__`` or
-``__init__`` as appropriate. Notes:
+You can convert ``tp_new`` and ``tp_init`` functions. Just name
+them ``__new__`` or ``__init__`` as appropriate. Notes:
* The function name generated for ``__new__`` doesn't end in ``__new__``
like it would by default. It's just the name of the class, converted
@@ -1290,9 +1298,13 @@ functions. Just name them ``__new__`` or
* ``__init__`` functions return ``int``, not ``PyObject *``.
-* Argument Clinic supports any signature for these functions, even though
- the parsing function is required to always take ``args`` and ``kwargs``
- objects.
+* Use the docstring as the class docstring.
+
+* Although ``__new__`` and ``__init__`` functions must always
+ accept both the ``args`` and ``kwargs`` objects, when converting
+ you may specify any signature for these functions that you like.
+ (If your function doesn't support keywords, the parsing function
+ generated will throw an exception if it receives any.)
The #ifdef trick
----------------------------------------------