summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-27 10:40:20 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-11-27 10:40:20 (GMT)
commitff737954f3ee3005236133fc51b55a508b11aa06 (patch)
treeb65ae9e39e774bd73674b5088e549d09a7bfd7d6 /Doc/library
parent0d3fb8a944a810f421377d5823cbc006700b3c1d (diff)
downloadcpython-ff737954f3ee3005236133fc51b55a508b11aa06.zip
cpython-ff737954f3ee3005236133fc51b55a508b11aa06.tar.gz
cpython-ff737954f3ee3005236133fc51b55a508b11aa06.tar.bz2
Removed the API to create unbound methods and simplified the API for bound methods. The signature is PyMethod_New(func, instance).
Also removed im_class and renamed im_self to __self__ and im_func to __func__. im_class can be substituted with method.__self__.__class__. I've also updated some parts of the documenation.
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/inspect.rst9
-rw-r--r--Doc/library/new.rst6
-rw-r--r--Doc/library/stdtypes.rst14
3 files changed, 13 insertions, 16 deletions
diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst
index cf14de9..988b737 100644
--- a/Doc/library/inspect.rst
+++ b/Doc/library/inspect.rst
@@ -49,14 +49,11 @@ attributes:
| | __name__ | name with which this |
| | | method was defined |
+-----------+-----------------+---------------------------+
-| | im_class | class object that asked |
-| | | for this method |
-+-----------+-----------------+---------------------------+
-| | im_func | function object |
+| | __func__ | function object |
| | | containing implementation |
| | | of method |
+-----------+-----------------+---------------------------+
-| | im_self | instance to which this |
+| | __self__ | instance to which this |
| | | method is bound, or |
| | | ``None`` |
+-----------+-----------------+---------------------------+
@@ -264,7 +261,7 @@ attributes:
Methods implemented via descriptors that also pass one of the other tests
return false from the :func:`ismethoddescriptor` test, simply because the
other tests promise more -- you can, e.g., count on having the
- :attr:`im_func` attribute (etc) when an object passes :func:`ismethod`.
+ :attr:`__func__` attribute (etc) when an object passes :func:`ismethod`.
.. function:: isdatadescriptor(object)
diff --git a/Doc/library/new.rst b/Doc/library/new.rst
index 6153ff1..6c5a4bf 100644
--- a/Doc/library/new.rst
+++ b/Doc/library/new.rst
@@ -17,10 +17,10 @@ non-sensical arguments which crash the interpreter when the object is used.
The :mod:`new` module defines the following functions:
-.. function:: instancemethod(function, instance, class)
+.. function:: instancemethod(function, instance)
- This function will return a method object, bound to *instance*, or unbound if
- *instance* is ``None``. *function* must be callable.
+ This function will return a method object, bound to *instance*.
+ *function* must be callable.
.. function:: function(code, globals[, name[, argdefs[, closure]]])
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index e6f7e7b..1e81ed9 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -2216,21 +2216,21 @@ instance methods. Built-in methods are described with the types that support
them.
The implementation adds two special read-only attributes to class instance
-methods: ``m.im_self`` is the object on which the method operates, and
-``m.im_func`` is the function implementing the method. Calling ``m(arg-1,
-arg-2, ..., arg-n)`` is completely equivalent to calling ``m.im_func(m.im_self,
-arg-1, arg-2, ..., arg-n)``.
+methods: ``m.__self__`` is the object on which the method operates, and
+``m.__func__`` is the function implementing the method. Calling ``m(arg-1,
+arg-2, ..., arg-n)`` is completely equivalent to calling ``m.__func__(
+m.__self__, arg-1, arg-2, ..., arg-n)``.
Class instance methods are either *bound* or *unbound*, referring to whether the
method was accessed through an instance or a class, respectively. When a method
-is unbound, its ``im_self`` attribute will be ``None`` and if called, an
+is unbound, its ``__self__`` attribute will be ``None`` and if called, an
explicit ``self`` object must be passed as the first argument. In this case,
``self`` must be an instance of the unbound method's class (or a subclass of
that class), otherwise a :exc:`TypeError` is raised.
Like function objects, methods objects support getting arbitrary attributes.
However, since method attributes are actually stored on the underlying function
-object (``meth.im_func``), setting method attributes on either bound or unbound
+object (``meth.__func__``), setting method attributes on either bound or unbound
methods is disallowed. Attempting to set a method attribute results in a
:exc:`TypeError` being raised. In order to set a method attribute, you need to
explicitly set it on the underlying function object::
@@ -2240,7 +2240,7 @@ explicitly set it on the underlying function object::
pass
c = C()
- c.method.im_func.whoami = 'my name is c'
+ c.method.__func__.whoami = 'my name is c'
See :ref:`types` for more information.