Skip to content

Commit 77a701a

Browse files
authored
Merge branch 'main' into accelerate_DJBX33A
2 parents b171e09 + acda175 commit 77a701a

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

Doc/howto/descriptor.rst

+21-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. _descriptorhowto:
22

3-
======================
4-
Descriptor HowTo Guide
5-
======================
3+
================
4+
Descriptor Guide
5+
================
66

77
:Author: Raymond Hettinger
88
:Contact: <python at rcn dot com>
@@ -1192,6 +1192,10 @@ roughly equivalent to:
11921192
"Emulate method_getattro() in Objects/classobject.c"
11931193
return getattr(self.__func__, name)
11941194

1195+
def __get__(self, obj, objtype=None):
1196+
"Emulate method_descr_get() in Objects/classobject.c"
1197+
return self
1198+
11951199
To support automatic creation of methods, functions include the
11961200
:meth:`__get__` method for binding methods during attribute access. This
11971201
means that functions are non-data descriptors that return bound methods
@@ -1214,8 +1218,20 @@ descriptor works in practice:
12141218
.. testcode::
12151219

12161220
class D:
1217-
def f(self, x):
1218-
return x
1221+
def f(self):
1222+
return self
1223+
1224+
class D2:
1225+
pass
1226+
1227+
.. doctest::
1228+
:hide:
1229+
1230+
>>> d = D()
1231+
>>> d2 = D2()
1232+
>>> d2.f = d.f.__get__(d2, D2)
1233+
>>> d2.f() is d
1234+
True
12191235

12201236
The function has a :term:`qualified name` attribute to support introspection:
12211237

Doc/howto/sorting.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.. _sortinghowto:
22

3-
Sorting HOW TO
4-
**************
3+
Sorting Techniques
4+
******************
55

66
:Author: Andrew Dalke and Raymond Hettinger
77

0 commit comments

Comments
 (0)