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

Random Remarks in class documentation #56843

Closed
atsengg mannequin opened this issue Jul 25, 2011 · 12 comments
Closed

Random Remarks in class documentation #56843

atsengg mannequin opened this issue Jul 25, 2011 · 12 comments
Assignees
Labels
3.8 only security fixes 3.9 only security fixes docs Documentation in the Doc dir easy

Comments

@atsengg
Copy link
Mannequin

atsengg mannequin commented Jul 25, 2011

BPO 12634
Nosy @rhettinger, @terryjreedy, @ezio-melotti, @merwok
PRs
  • bpo-12634: Clarify an awkward section of the tutorial #15406
  • [3.8] bpo-12634: Clarify an awkward section of the tutorial (GH-15406) #15409
  • Files
  • issue12634.patch
  • issue12634-27.patch
  • 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/rhettinger'
    closed_at = <Date 2019-08-23.06:46:25.514>
    created_at = <Date 2011-07-25.06:36:50.164>
    labels = ['easy', '3.8', '3.9', 'docs']
    title = 'Random Remarks in class documentation'
    updated_at = <Date 2019-08-23.06:46:25.514>
    user = 'https://bugs.python.org/atsengg'

    bugs.python.org fields:

    activity = <Date 2019-08-23.06:46:25.514>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2019-08-23.06:46:25.514>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2011-07-25.06:36:50.164>
    creator = 'ats.engg'
    dependencies = []
    files = ['30134', '30135']
    hgrepos = []
    issue_num = 12634
    keywords = ['patch', 'easy']
    message_count = 12.0
    messages = ['141073', '141074', '141078', '141089', '141103', '174672', '174753', '187691', '188444', '188445', '350252', '350254']
    nosy_count = 9.0
    nosy_names = ['rhettinger', 'terry.reedy', 'fossilet', 'ezio.melotti', 'eric.araujo', 'cvrebert', 'docs@python', 'ats.engg', 'Yogesh.Chaudhari']
    pr_nums = ['15406', '15409']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue12634'
    versions = ['Python 3.8', 'Python 3.9']

    @atsengg
    Copy link
    Mannequin Author

    atsengg mannequin commented Jul 25, 2011

    URL: http://docs.python.org/tutorial/classes.html
    section: 9.4 Random Remarks

    The first sentense is bit confusing:
    "Data attributes override method attributes with the same name"

    Is it possible to change the sentense something like this:
    "Data attributes set through instance override method attributes with the same name"

    @atsengg atsengg mannequin assigned docspython Jul 25, 2011
    @atsengg atsengg mannequin added type-feature A feature request or enhancement docs Documentation in the Doc dir labels Jul 25, 2011
    @rhettinger
    Copy link
    Contributor

    The proposed rewrite doesn't make any sense to me. Also "set through" is an reads awkwardly.

    @rhettinger rhettinger assigned rhettinger and unassigned docspython Jul 25, 2011
    @ezio-melotti
    Copy link
    Member

    Indeed that paragraph is not really clear. I had to read it till the end ("verbs for methods and nouns for data attributes") to figure out what it was talking about. Even then it's still not clear what it's trying to say.
    I *think* it means that if you have a class Foo with a method bar, and you do Foo.bar = 'data', the method will be overridden (so you won't be able to do Foo.bar for the 'data' and Foo.bar() for the method), but the opposite is also true.
    Moreover I find both the suggestions for avoiding conflicts (capitalizing method names and/or using an underscore) wrong (both against PEP-8). Also it never happened to me to have an attribute with the same name of a method, and I think in general it's not a common case (becase, as the paragraph says, methods are verbs and attributes nouns).

    The whole thing could be rewritten to just say that an attribute name always refers to a single object, either to a method or to some "data".

    @merwok
    Copy link
    Member

    merwok commented Jul 25, 2011

    I have the same reading as Ezio, and the same opinion that it’s unclear and unhelpful. +1 to saying that there is only one namespace for data attributes and methods.

    @terryjreedy
    Copy link
    Member

    That sentence is wrong to imply that there is anything special about data versus method attributes with respect to overriding -- or that attributes are special when it comes to names in a single namespace. What I think the paragraph should say, if not just deleted, is something like.

    "Instance attributes hide class attributes. Instance data names are often intended to override class data names. But instance data names masking methods names is likely a mistake. This can be avoided by using verbs for method names and nouns for data names."

    @merwok
    Copy link
    Member

    merwok commented Nov 3, 2012

    +1 to something like Terry’s proposal.

    @merwok merwok added easy and removed type-feature A feature request or enhancement labels Nov 3, 2012
    @ezio-melotti
    Copy link
    Member

    See also bpo-16048.

    @fossilet
    Copy link
    Mannequin

    fossilet mannequin commented Apr 24, 2013

    It may be worth to noting that when creating property attribute using the property decorator, we may tend to name the method using nouns, like here:
    http://docs.python.org/2/library/functions.html#property

    This is when I once overided data attribute with method.

    @YogeshChaudhari
    Copy link
    Mannequin

    YogeshChaudhari mannequin commented May 5, 2013

    Based on Teery's comments, this patch makes the changes to the random remarks section of the class documentation

    @YogeshChaudhari
    Copy link
    Mannequin

    YogeshChaudhari mannequin commented May 5, 2013

    Similar changes for 2.7 branch

    @rhettinger rhettinger added 3.8 only security fixes 3.9 only security fixes labels Aug 22, 2019
    @rhettinger
    Copy link
    Contributor

    New changeset 483ae0c by Raymond Hettinger in branch 'master':
    bpo-12634: Clarify an awkward section of the tutorial (GH-15406)
    483ae0c

    @rhettinger
    Copy link
    Contributor

    New changeset f6a7f5b by Raymond Hettinger (Miss Islington (bot)) in branch '3.8':
    bpo-12634: Clarify an awkward section of the tutorial (GH-15406) (GH-15409)
    f6a7f5b

    @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
    3.8 only security fixes 3.9 only security fixes docs Documentation in the Doc dir easy
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants