New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove unneeded '(object)' from 3.x class examples #54575
Comments
In 3.x, "(object)" is now superfluous in class statements. Reference manual 7.7. Class definitions has simply 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 |
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/adapter_point_2.py:3:class Point(object):
includes/sqlite3/converter_point.py:3:class Point(object):
includes/sqlite3/adapter_point_1.py:3:class Point(object):
includes/mp_newtype.py:15:class Foo(object): |
Attached a patch to implement the suggested changes on 3.2. If the patch is ok I can do the same for 3.1. |
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. |
Hi eric, what doc change are you referring to? |
“I also think the doc for 'class' should say that the default inheritance is from the base class *object*” |
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. |
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. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: