Mailing List Archive

CVS: python/dist/src/Doc/api newtypes.tex,1.3,1.4
Update of /cvsroot/python/python/dist/src/Doc/api
In directory usw-pr-cvs1:/tmp/cvs-serv5683/Doc/api

Modified Files:
newtypes.tex
Log Message:
Introduce two new flag bits that can be set in a PyMethodDef method
descriptor, as used for the tp_methods slot of a type. These new flag
bits are both optional, and mutually exclusive. Most methods will not
use either. These flags are used to create special method types which
exist in the same namespace as normal methods without having to use
tedious construction code to insert the new special method objects in
the type's tp_dict after PyType_Ready() has been called.

If METH_CLASS is specified, the method will represent a class method
like that returned by the classmethod() built-in.

If METH_STATIC is specified, the method will represent a static method
like that returned by the staticmethod() built-in.

These flags may not be used in the PyMethodDef table for modules since
these special method types are not meaningful in that case; a
ValueError will be raised if these flags are found in that context.


Index: newtypes.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/api/newtypes.tex,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** newtypes.tex 3 Dec 2001 17:32:27 -0000 1.3
--- newtypes.tex 28 Mar 2002 05:33:33 -0000 1.4
***************
*** 153,158 ****
implementation uses a the specific C type of the \var{self} object.

! The flags can have the following values. Only \constant{METH_VARARGS}
! and \constant{METH_KEYWORDS} can be combined; the others can't.

\begin{datadesc}{METH_VARARGS}
--- 153,162 ----
implementation uses a the specific C type of the \var{self} object.

! The \member{ml_flags} field is a bitfield which can include the
! following flags. The individual flags indicate either a calling
! convention or a binding convention. Of the calling convention flags,
! only \constant{METH_VARARGS} and \constant{METH_KEYWORDS} can be
! combined. Any of the calling convention flags can be combined with a
! binding flag.

\begin{datadesc}{METH_VARARGS}
***************
*** 203,206 ****
--- 207,234 ----
argument.
\end{datadesc}
+
+ These two constants are not used to indicate the calling convention
+ but the binding when use with methods of classes. These may not be
+ used for functions defined for modules. At most one of these flags
+ may be set for any given method.
+
+ \begin{datadesc}{METH_CLASS}
+ The method will be passed the type object as the first parameter
+ rather than an instance of the type. This is used to create
+ \emph{class methods}, similar to what is created when using the
+ \function{classmethod()}\bifuncindex{classmethod} built-in
+ function.
+ \versionadded{2.3}
+ \end{datadesc}
+
+ \begin{datadesc}{METH_STATIC}
+ The method will be passed \NULL{} as the first parameter rather than
+ an instance of the type. This is used to create \emph{static
+ methods}, similar to what is created when using the
+ \function{staticmethod()}\bifuncindex{staticmethod} built-in
+ function.
+ \versionadded{2.3}
+ \end{datadesc}
+

\begin{cfuncdesc}{PyObject*}{Py_FindMethod}{PyMethodDef table[],