[Python-checkins] cpython (3.4): #14201: Update ctypes docs to match behavior changed from 214b28d7a999.

r.david.murray python-checkins at python.org
Sun Oct 5 00:26:54 CEST 2014


https://hg.python.org/cpython/rev/5518aa0fbc06
changeset:   92816:5518aa0fbc06
branch:      3.4
parent:      92813:a6906b9e21d5
user:        R David Murray <rdmurray at bitdance.com>
date:        Sat Oct 04 18:25:07 2014 -0400
summary:
  #14201: Update ctypes docs to match behavior changed from 214b28d7a999.

Original patch by Erik Johansson, slightly updated by Meador Inge.

files:
  Doc/library/ctypes.rst |  15 ++++++++++-----
  1 files changed, 10 insertions(+), 5 deletions(-)


diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst
--- a/Doc/library/ctypes.rst
+++ b/Doc/library/ctypes.rst
@@ -1386,11 +1386,16 @@
    The default mode which is used to load shared libraries.  On OSX 10.3, this is
    *RTLD_GLOBAL*, otherwise it is the same as *RTLD_LOCAL*.
 
-Instances of these classes have no public methods, however :meth:`__getattr__`
-and :meth:`__getitem__` have special behavior: functions exported by the shared
-library can be accessed as attributes of by index.  Please note that both
-:meth:`__getattr__` and :meth:`__getitem__` cache their result, so calling them
-repeatedly returns the same object each time.
+Instances of these classes have no public methods.  Functions exported by the
+shared library can be accessed as attributes or by index.  Please note that
+accessing the function through an attribute caches the result and therefore
+accessing it repeatedly returns the same object each time.  On the other hand,
+accessing it through an index returns a new object each time:
+
+   >>> libc.time == libc.time
+   True
+   >>> libc['time'] == libc['time']
+   False
 
 The following public attributes are available, their name starts with an
 underscore to not clash with exported function names:

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list