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

Add the word "operator" before symbolic magic methods #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eric-wieser
Copy link
Collaborator

This perhaps helps the reader understand why they're seeing symbols in the function name.

We should probably do the same thing for the function overloads, but I'm not sure what the appropriate prefix would be. Some options are:

  • operator len(x), operator operator.index(x)
  • implements len(x), implements operator.index(x)
  • supports len(x), supports operator.index(x)

etc. Without some kind of marker, it's impossible to distinguish len(x) from x.len(self=...) in the docs.

This perhaps helps the reader understand why they're seeing symbols in the function name.

We should probably do the same thing for the function overloads, but I'm not sure what the appropriate prefix would be. Some options are:

* `operator len(x)`, `operator operator.index(x)`
* `implements len(x)`, `implements operator.index(x)`
* `supports len(x)`, `supports operator.index(x)`

etc. Without some kind of marker, it's impossible to distinguish `len(x)` from `x.len(self=...)` in the docs.
@eric-wieser
Copy link
Collaborator Author

@tk0miya, do you have any opinions on what the right prefix for len(self) would be to indicate it's referring to __len__?

@eric-wieser eric-wieser requested a review from tk0miya June 3, 2020 08:26
@johnpmcconnell
Copy link

johnpmcconnell commented Feb 18, 2021

I don't think this is necessary. The Python Reference doesn't do this when it documents operators. See dict's key access.

If you feel the need to distinguish special method implementations, I'd suggest changing something about the formatting instead of prefixing a word. The Python Reference's documentation does look slightly different for these protocols, but I believe that's because they're forced to use manual formatting at present.

Of the options you've presented, though, I favor "supports." These are typically referred to as "protocols" in my experience, and I think "supports" best describes the relationship to the language defined syntaxes and standard library defined methods associated with special methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants