An instance method is a wrapper for a
and the new way to bind a PyCFunction to a class object. It replaces the former call PyMethod_New(func,NULL,class).
PyInstanceMethod_Type
This instance of
represents the Python instance method type. It is not exposed to Python programs.
intPyInstanceMethod_Check(
*o)
Return true if o is an instance method object (has type
). The parameter must not be NULL. This function always succeeds.
*PyInstanceMethod_New(
*func)
Return value: New reference.Return a new instance method object, with func being any callable object. func is the function that will be called when the instance method is called.
*PyInstanceMethod_Function(
*im)
Return value: Borrowed reference.Return the function object associated with the instance method im.
*PyInstanceMethod_GET_FUNCTION(
*im)
Return value: Borrowed reference.Macro version of
which avoids error checking.
Method Objects
Methods are bound function objects. Methods are always bound to an instance of a user-defined class. Unbound methods (methods bound to a class object) are no longer available.
PyMethod_Type
This instance of
represents the Python method type. This is exposed to Python programs as types.MethodType.
intPyMethod_Check(
*o)
Return true if o is a method object (has type
). The parameter must not be NULL. This function always succeeds.
*PyMethod_New(
*func,
*self)
Return value: New reference.Return a new method object, with func being any callable object and self the instance the method should be bound. func is the function that will be called when the method is called. self must not be NULL.
*PyMethod_Function(
*meth)
Return value: Borrowed reference.Return the function object associated with the method meth.
*PyMethod_GET_FUNCTION(
*meth)
Return value: Borrowed reference.Macro version of
which avoids error checking.
*PyMethod_Self(
*meth)
Return value: Borrowed reference.Return the instance associated with the method meth.
*PyMethod_GET_SELF(
*meth)
Return value: Borrowed reference.Macro version of
which avoids error checking.