Skip to content
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

Closed
terryjreedy opened this issue Nov 8, 2010 · 8 comments
Closed

Remove unneeded '(object)' from 3.x class examples #54575

terryjreedy opened this issue Nov 8, 2010 · 8 comments
Assignees
Labels
docs Documentation in the Doc dir easy

Comments

@terryjreedy
Copy link
Member

BPO 10366
Nosy @rhettinger, @terryjreedy, @abalkin, @merwok, @IIIIllllIIIIllllIIIIllllIIIIllllIIIIll
Files
  • issue10366_remove_unneeded_object_py3.2.diff
  • 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:

    assignee = 'https://github.com/merwok'
    closed_at = <Date 2010-11-22.03:20:35.071>
    created_at = <Date 2010-11-08.19:19:09.302>
    labels = ['easy', 'docs']
    title = "Remove unneeded '(object)' from 3.x class examples"
    updated_at = <Date 2010-11-22.03:20:35.070>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2010-11-22.03:20:35.070>
    actor = 'eric.araujo'
    assignee = 'eric.araujo'
    closed = True
    closed_date = <Date 2010-11-22.03:20:35.071>
    closer = 'eric.araujo'
    components = ['Documentation']
    creation = <Date 2010-11-08.19:19:09.302>
    creator = 'terry.reedy'
    dependencies = []
    files = ['19591']
    hgrepos = []
    issue_num = 10366
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['120795', '120798', '121115', '122034', '122043', '122045', '122046', '122081']
    nosy_count = 6.0
    nosy_names = ['rhettinger', 'terry.reedy', 'belopolsky', 'eric.araujo', 'docs@python', 'xuanji']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue10366'
    versions = ['Python 3.1', 'Python 3.2']

    @terryjreedy
    Copy link
    Member Author

    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!).

    @terryjreedy terryjreedy added docs Documentation in the Doc dir easy labels Nov 8, 2010
    @merwok
    Copy link
    Member

    merwok commented Nov 8, 2010

    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):

    @IIIIllllIIIIllllIIIIllllIIIIllllIIIIll
    Copy link
    Mannequin

    Attached a patch to implement the suggested changes on 3.2. If the patch is ok I can do the same for 3.1.

    @merwok
    Copy link
    Member

    merwok commented Nov 22, 2010

    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.

    @merwok merwok assigned merwok and unassigned docspython Nov 22, 2010
    @IIIIllllIIIIllllIIIIllllIIIIllllIIIIll
    Copy link
    Mannequin

    Hi eric, what doc change are you referring to?

    @merwok
    Copy link
    Member

    merwok commented Nov 22, 2010

    “I also think the doc for 'class' should say that the default inheritance is from the base class *object*”

    @rhettinger
    Copy link
    Contributor

    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.

    @merwok
    Copy link
    Member

    merwok commented Nov 22, 2010

    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.

    @merwok merwok closed this as completed Nov 22, 2010
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir easy
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants