Title: Remove unneeded '(object)' from 3.x class examples
Type: Stage: resolved
Components: Documentation Versions: Python 3.1, Python 3.2
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: belopolsky, docs@python, eric.araujo, rhettinger, terry.reedy, xuanji
Priority: normal Keywords: easy, patch

Created on 2010-11-08 19:19 by terry.reedy, last changed 2010-11-22 03:20 by eric.araujo. This issue is now closed.

File name Uploaded Description Edit
issue10366_remove_unneeded_object_py3.2.diff xuanji, 2010-11-13 05:51
Messages (8)
msg120795 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-11-08 19:19
In 3.x, "(object)" is now superfluous in class statements. Reference manual 7.7. Class definitions has simply
    class Foo: pass

In library manual 2. Built-in Functions, class examples for classmethod and staticmethod are the same. Class examples for dir, property, and type still have '(object)' in their class examples. Section 5.11.4. Methods example omits it. I cannot think of anywhere else there should be such examples.

I think we should be consistent and remove the remaining occurrences of '(object)' in the function examples. They can only confuse newcomers.

This part is easy.

I also think the doc for 'class' should say that the default inheritance is from the base class *object* (I presume this should be true in all implementations) and that 
    class Foo(object): pass
is the same as the above (unless the name 'object' has been rebound!).
msg120798 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-08 19:51
Other unneeded uses of object, courtesy of grep:

library/sqlite3.rst:713:   class Point(object):
library/multiprocessing.rst:1335:   class MathsClass(object):
library/functions.rst:281:      >>> class Foo(object):
library/functions.rst:897:      class C(object):
library/functions.rst:916:      class Parrot(object):
library/functions.rst:933:      class C(object):
library/functions.rst:1237:      >>> class X(object):
library/argparse.rst:1315:   >>> class C(object):
library/ctypes.rst:372:   >>> class Bottles(object):
library/itertools.rst:326:      class groupby(object):
howto/descriptor.rst:156:    class RevealAccess(object):
howto/descriptor.rst:173:    >>> class MyClass(object):
howto/descriptor.rst:205:    class C(object):
howto/descriptor.rst:214:    class Property(object):
howto/descriptor.rst:250:    class Cell(object):
howto/descriptor.rst:278:    class Function(object):
howto/descriptor.rst:286:    >>> class D(object):
howto/descriptor.rst:358:    >>> class E(object):
howto/descriptor.rst:371:    class StaticMethod(object):
howto/descriptor.rst:384:    >>> class E(object):
howto/descriptor.rst:419:    class ClassMethod(object):
howto/sorting.rst:228:        class K(object):
reference/datamodel.rst:1990:   >>> class C(object):
includes/sqlite3/ Point(object):
includes/sqlite3/ Point(object):
includes/sqlite3/ Point(object):
includes/ Foo(object):
msg121115 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-13 05:51
Attached a patch to implement the suggested changes on 3.2. If the patch is ok I can do the same for 3.1.
msg122034 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-22 00:11
I will commit the patch this week unless someone opposes to it.

We still need a doc change as described in Terry’s original message.
msg122043 - (view) Author: Xuanji Li (xuanji) * Date: 2010-11-22 00:26
Hi eric, what doc change are you referring to?
msg122045 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-22 00:27
“I also think the doc for 'class' should say that the default inheritance is from the base class *object*”
msg122046 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-11-22 00:33
These mostly look good.  Do leave the howto documents as-is.  They have some value across multiple versions of Python.  Also, the descriptor how-to in particular gets some benefit from keeping (object) explicit because it helps remind users which version of __getattribute__ is being run.

Other than the how-tos, please go ahead and apply.
msg122081 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-22 03:20
The patch actually already contained a doc change addressing Terry’s second request, thank you Xuanji Li.  I reverted the changes to howto as per Raymond’s comment, made some other slight editions (like removing trailing whitespace) and committed as r86670 and r86672.
Date User Action Args
2010-11-22 03:20:35eric.araujosetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg122081

stage: patch review -> resolved
2010-11-22 00:33:09rhettingersetnosy: + rhettinger
messages: + msg122046
2010-11-22 00:27:03eric.araujosetmessages: + msg122045
2010-11-22 00:26:13xuanjisetstatus: pending -> open

messages: + msg122043
2010-11-22 00:11:59eric.araujosetstatus: open -> pending
messages: + msg122034

assignee: docs@python -> eric.araujo
resolution: accepted
stage: needs patch -> patch review
2010-11-13 05:51:14xuanjisetfiles: + issue10366_remove_unneeded_object_py3.2.diff

nosy: + xuanji
messages: + msg121115

keywords: + patch
2010-11-08 19:52:51belopolskysetnosy: + belopolsky
2010-11-08 19:51:36eric.araujosetnosy: + eric.araujo
messages: + msg120798
2010-11-08 19:19:09terry.reedycreate