| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| Expand Up | @@ -687,9 +687,14 @@ callable object (normally a user-defined function). | |||||
| single: __name__ (method attribute) | ||||||
| single: __module__ (method attribute) | ||||||
|
|
||||||
| Special read-only attributes: | ||||||
| Special read-only attributes | ||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||
|
|
||||||
| .. list-table:: | ||||||
| :header-rows: 1 | ||||||
|
|
||||||
| * - Attribute | ||||||
| - Meaning | ||||||
|
|
||||||
| * - .. attribute:: method.__self__ | ||||||
| - Refers to the class instance object to which the method is | ||||||
| Expand Down Expand Up | @@ -818,15 +823,41 @@ Built-in functions | |||||
| A built-in function object is a wrapper around a C function. Examples of | ||||||
| built-in functions are :func:`len` and :func:`math.sin` (:mod:`math` is a | ||||||
| standard built-in module). The number and type of the arguments are | ||||||
| determined by the C function. Special read-only attributes: | ||||||
|
|
||||||
| * :attr:`!__doc__` is the function's documentation string, or ``None`` if | ||||||
| unavailable. See :attr:`function.__doc__`. | ||||||
| * :attr:`!__name__` is the function's name. See :attr:`function.__name__`. | ||||||
| * :attr:`!__self__` is set to ``None`` (but see the next item). | ||||||
| * :attr:`!__module__` is the name of | ||||||
| the module the function was defined in or ``None`` if unavailable. | ||||||
| See :attr:`function.__module__`. | ||||||
| determined by the C function. | ||||||
|
|
||||||
| Special read-only attributes | ||||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||||||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySame here, I'm not sure it really makes sense to make this a distinct subsection when there aren't any other subsections inside the datamodel section on builtin functions
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI thought about that, and I decided by subsection because:
Actually, when I opened the issue, I thought about a unique table for both attributes with a column to identify the kind, as the User-defined functions section was before your recent changes.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThose are all reasonable points! I don't mind the new subsection in the section on builtin functions too much; I'm happy for that to stay. I do think the new subsection in the section on instance methods makes it more confusing, however. It implies that the entirety of the section on instance methods is about their special read-only attributes, except for the first paragraph. This isn't true: the final paragraph in section 3.2.8.2 has nothing to do with the special read-only methods of instance methods:
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWhat if do we move this paragraph to the second paragraph? This seems an explanation for the first one.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWell, what about these two paragraphs?
The first paragraph is about the special read-only attributes of method objects; the second one isn't (it's about a broader topic to do with the semantics of Python methods). So maybe we should move the second paragraph out of the section about the special read-only attributes -- but that would make no sense; it's much more logical to talk about how the self reference is inserted at the beginning of the argument list after we've talked about the special __self__ attribute. The two paragraphs belong together. For the section on instance methods, I think the existing structure -- where the special read-only attributes are discussed at the same time as other details on method semantics -- makes most sense. Unless you want to propose reworking the whole section on instance methods (which should go into a separate PR, IMO), I don't think we should add a subsection just for the read-only attributes.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualityit's about a broader topic to do with the semantics of Python methods Despite this, I think that we can consider all these paragraphs as about the attributes. They talk about how the attributes work together to element (object, class, method..) to work as well. The attributes are cited a lot of time. In first look, I understand this paragraph under attributes this way. However, I also noted some paragraphs didn't are about the attribute, but about the element. I would propose moving these paragraphs to the introduction of the section, probrably. Another two idea are:
I prefer first option (although more work), but the second one also provide consistence. Unless you want to propose reworking the whole section on instance methods (which should go into a separate PR, IMO), Shall we do this together. Some details about it can scape me. :) I think what I told above is in this direction. (Sorry for any confused thought. It is a brainstorm)
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI'm sorry, but I still disagree that using a subsection for the Instance methods section is the right way to go there, at least the way you've currently done it in this PR :/ I'd be happy to look at a broader rewrite of that section, because I agree that consistency between the different sections is nice. But unfortunately I don't really have time to push forward on that right now (and I doubt I will until PyCon).
Sorry, something went wrong.
All reactions
|
||||||
|
|
||||||
| .. list-table:: | ||||||
| :header-rows: 1 | ||||||
|
|
||||||
| * - Attribute | ||||||
| - Meaning | ||||||
|
|
||||||
| * - .. attribute:: builtin_function.__class__ | ||||||
| - The function's class. | ||||||
|
|
||||||
|
Comment thread
Comment on lines
+837
to
+839
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThis attribute is present on all Python objects everywhere, and is already documented as such here: https://docs.python.org/3/library/stdtypes.html#special-attributes. Please revert this addition; there's no need to duplicate that documentation here.
Suggested change
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIn fact, I've realized that attribute definition duplication is a problem in this chapter. See __doc__ and __name__ attributes, e.g. I'm thinking about a kind of hierarchy: a section with all common attributes and in each callable type something like "the attributes are those above plus these more: ... ". The content that you highlighted now is a good beginning in this direction. However, Reference Language must be referenced by the Library Reference. Besides, we don't have a reference to the cited content in this chapter. Also, I found the attribute definitions in the inspect module documentation. This could be erased and added a refer to the Language Reference. In my opinion, the Language Reference is more important than other sections. All other sections must refer to the Reference, not the contrary. So, my suggestion is:
What do you think? Any other ideas?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityYes, I've been working towards similar goals to you in my recent PRs #112781, #112933, #112735, etc. My opinions:
Sorry, something went wrong.
adorilson reacted with thumbs up emoji
All reactions
Copy link
Copy Markdown
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
My suggestion is to put the list on The standard type hierarchy. The second paragraph already cited special attributes, so this seems like a good place to show them. Does it make sense for you?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySome things have changed since we had this conversation in March! Now, __class__ and __dict__ are documented as object.__class__ and object.__dict__, because they are present on all Python objects: https://docs.python.org/3/reference/datamodel.html#object.__class__, https://docs.python.org/3/reference/datamodel.html#object.__dict__. But __name__ and __doc__ are now more consistently listed for classes documented in the data model that define these attributes, and they are still listed in https://docs.python.org/3/library/stdtypes.html#special-attributes (because they do not exist on all Python objects). All things considered, I still think it's incorrect for the __class__ attribute to be documented here, since it doesn't really add anything to the documentation at https://docs.python.org/3/reference/datamodel.html#object.__class__. So my original request remains: please get rid of this bullet point :-)
Let's have this conversation in an issue or PR elsewhere; the question doesn't really seem relevant to this PR :-) Maybe the list should be moved out of stdtypes into the datamodel, and maybe not -- whatever the case, I don't think it should be done as part of this PR :-)
Sorry, something went wrong.
hugovk reacted with thumbs up emoji
All reactions
|
||||||
| * - .. attribute:: builtin_function.__doc__ | ||||||
| - The function's documentation string, or ``None`` if unavailable. | ||||||
| See :attr:`function.__doc__`. | ||||||
|
|
||||||
| * - .. attribute:: builtin_function.__module__ | ||||||
| - The name of the module the function was defined in, | ||||||
| or ``None`` if unavailable. See :attr:`function.__module__`. | ||||||
|
|
||||||
| * - .. attribute:: builtin_function.__name__ | ||||||
| - The function's name. | ||||||
| See :attr:`function.__name__`. | ||||||
|
|
||||||
| * - .. attribute:: builtin_function.__qualname__ | ||||||
| - The function's :term:`qualified name`. | ||||||
| See also: :attr:`__qualname__ attributes <definition.__qualname__>`. | ||||||
|
|
||||||
| * - .. attribute:: builtin_function.__self__ | ||||||
| - This is always ``None`` (see :ref:`built-in methods <builtin-methods>`). | ||||||
|
|
||||||
| * - .. attribute:: builtin_function.__text_signature__ | ||||||
| - The function's signature as plain text, or ``None`` if unavailable. | ||||||
|
|
||||||
|
|
||||||
| .. _builtin-methods: | ||||||
| Expand Down | ||||||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI don't think it really makes sense to make this a separate subsection, since there are no other subsections inside the datamodel section on instance methods. I'd just keep this as a sentence ending with a colon, personally
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.