Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e042a45

Browse files
Do not use explicit inheritance from object in the documentation. (GH-13936)
1 parent c879ff2 commit e042a45

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

Doc/howto/descriptor.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ print a message for each get or set. Overriding :meth:`__getattribute__` is
145145
alternate approach that could do this for every attribute. However, this
146146
descriptor is useful for monitoring just a few chosen attributes::
147147

148-
class RevealAccess(object):
148+
class RevealAccess:
149149
"""A data descriptor that sets and returns values
150150
normally and prints a message logging their access.
151151
"""
@@ -162,7 +162,7 @@ descriptor is useful for monitoring just a few chosen attributes::
162162
print('Updating', self.name)
163163
self.val = val
164164

165-
>>> class MyClass(object):
165+
>>> class MyClass:
166166
... x = RevealAccess(10, 'var "x"')
167167
... y = 5
168168
...
@@ -194,7 +194,7 @@ triggers function calls upon access to an attribute. Its signature is::
194194

195195
The documentation shows a typical use to define a managed attribute ``x``::
196196

197-
class C(object):
197+
class C:
198198
def getx(self): return self.__x
199199
def setx(self, value): self.__x = value
200200
def delx(self): del self.__x
@@ -203,7 +203,7 @@ The documentation shows a typical use to define a managed attribute ``x``::
203203
To see how :func:`property` is implemented in terms of the descriptor protocol,
204204
here is a pure Python equivalent::
205205

206-
class Property(object):
206+
class Property:
207207
"Emulate PyProperty_Type() in Objects/descrobject.c"
208208

209209
def __init__(self, fget=None, fset=None, fdel=None, doc=None):
@@ -250,7 +250,7 @@ to be recalculated on every access; however, the programmer does not want to
250250
affect existing client code accessing the attribute directly. The solution is
251251
to wrap access to the value attribute in a property data descriptor::
252252

253-
class Cell(object):
253+
class Cell:
254254
. . .
255255
def getvalue(self):
256256
"Recalculate the cell before returning value"
@@ -277,7 +277,7 @@ binding methods during attribute access. This means that all functions are
277277
non-data descriptors which return bound methods when they are invoked from an
278278
object. In pure Python, it works like this::
279279

280-
class Function(object):
280+
class Function:
281281
. . .
282282
def __get__(self, obj, objtype=None):
283283
"Simulate func_descr_get() in Objects/funcobject.c"
@@ -287,7 +287,7 @@ object. In pure Python, it works like this::
287287

288288
Running the interpreter shows how the function descriptor works in practice::
289289

290-
>>> class D(object):
290+
>>> class D:
291291
... def f(self, x):
292292
... return x
293293
...
@@ -367,7 +367,7 @@ It can be called either from an object or the class: ``s.erf(1.5) --> .9332`` o
367367
Since staticmethods return the underlying function with no changes, the example
368368
calls are unexciting::
369369

370-
>>> class E(object):
370+
>>> class E:
371371
... def f(x):
372372
... print(x)
373373
... f = staticmethod(f)
@@ -380,7 +380,7 @@ calls are unexciting::
380380
Using the non-data descriptor protocol, a pure Python version of
381381
:func:`staticmethod` would look like this::
382382

383-
class StaticMethod(object):
383+
class StaticMethod:
384384
"Emulate PyStaticMethod_Type() in Objects/funcobject.c"
385385

386386
def __init__(self, f):
@@ -393,7 +393,7 @@ Unlike static methods, class methods prepend the class reference to the
393393
argument list before calling the function. This format is the same
394394
for whether the caller is an object or a class::
395395

396-
>>> class E(object):
396+
>>> class E:
397397
... def f(klass, x):
398398
... return klass.__name__, x
399399
... f = classmethod(f)
@@ -410,7 +410,7 @@ is to create alternate class constructors. In Python 2.3, the classmethod
410410
:func:`dict.fromkeys` creates a new dictionary from a list of keys. The pure
411411
Python equivalent is::
412412

413-
class Dict(object):
413+
class Dict:
414414
. . .
415415
def fromkeys(klass, iterable, value=None):
416416
"Emulate dict_fromkeys() in Objects/dictobject.c"
@@ -428,7 +428,7 @@ Now a new dictionary of unique keys can be constructed like this::
428428
Using the non-data descriptor protocol, a pure Python version of
429429
:func:`classmethod` would look like this::
430430

431-
class ClassMethod(object):
431+
class ClassMethod:
432432
"Emulate PyClassMethod_Type() in Objects/funcobject.c"
433433

434434
def __init__(self, f):

Doc/library/copyreg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The example below would like to show how to register a pickle function and how
4949
it will be used:
5050

5151
>>> import copyreg, copy, pickle
52-
>>> class C(object):
52+
>>> class C:
5353
... def __init__(self, a):
5454
... self.a = a
5555
...

Doc/library/functools.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ The :mod:`functools` module defines the following functions:
275275

276276
Example::
277277

278-
>>> class Cell(object):
278+
>>> class Cell:
279279
... def __init__(self):
280280
... self._alive = False
281281
... @property

0 commit comments

Comments
 (0)