Skip to content

documentation: numbers module nitpick #76314

Closed

Description

@abcdef
mannequin
BPO 32133
Nosy @rhettinger, @skirpichev, @miss-islington, @miguendes
PRs
  • bpo-32133: Improve numbers docs #26124
  • [3.9] bpo-32133: Improve numbers docs (GH-26124) #26147
  • [3.10] bpo-32133: Improve numbers docs (GH-26124) #26149
  • 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 2021-05-15.17:29:29.146>
    created_at = <Date 2017-11-25.18:31:43.555>
    labels = ['easy', '3.9', '3.10', '3.11', 'type-feature', 'docs']
    title = 'documentation: numbers module nitpick'
    updated_at = <Date 2021-05-15.17:29:29.146>
    user = 'https://bugs.python.org/abcdef'

    bugs.python.org fields:

    activity = <Date 2021-05-15.17:29:29.146>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2021-05-15.17:29:29.146>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2017-11-25.18:31:43.555>
    creator = 'abcdef'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32133
    keywords = ['patch', 'easy']
    message_count = 8.0
    messages = ['306970', '393636', '393673', '393679', '393705', '393706', '393720', '393721']
    nosy_count = 7.0
    nosy_names = ['rhettinger', 'docs@python', 'abcdef', 'Sergey.Kirpichev', 'miss-islington', 'miguendes', 'adityasriram.b']
    pr_nums = ['26124', '26147', '26149']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32133'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    Activity

    1. abcdef commented on Nov 25, 2017

      abcdefmannequin
      MannequinAuthor

      Documentation of the numbers module:
      https://docs.python.org/3/library/numbers.html
      states "None of the types defined in this module can be instantiated."

      This is true for Complex, Real, Rational, Integral but not for Number:

      >>> numbers.Number()
      <numbers.Number object at 0x7fcccc71f3c0>
      >>> numbers.Real()
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      TypeError: Can't instantiate abstract class Real...

      Since Number doesn't have any abstract methods, the correct fix seems to be changing the documentation. I would try to convey something like this:

      "The types defined in this module can be used for subclassing and checking whether a specific class is in the numeric hierarchy; they are not used directly for instantiation. For this, you can use types such as complex or fractions.Fraction".

    2. added
      docs
      type-feature
      on Nov 25, 2017
    3. added
      3.9 (EOL)
      3.10 (EOL)
      3.11
      on May 9, 2021
    4. miguendes commented on May 14, 2021

      miguendesmannequin
      Mannequin

      Seen that nobody is working on this I transformed the suggestion into a PR.

    5. adityasriramb commented on May 14, 2021

      adityasrirambmannequin
      Mannequin

      I would like work on this, but I'm very new to fixing bugs. Could someone please help me on how to proceed with this bug. Thank You in advance

    6. rhettinger commented on May 14, 2021

      @rhettinger
      Contributor

      Here's a minimal change:

      • None of the types defined in this module can be instantiated.
        + None of the types defined in this module are intended to be instantiated.
    7. miguendes commented on May 15, 2021

      miguendesmannequin
      Mannequin

      @rhettinger added your suggestion.

    8. skirpichev commented on May 15, 2021

      skirpichevmannequin
      Mannequin

      Maybe some methods from the Complex class could be moved to the Number class?

      I think, that something like the ring structure (probably even a commutative ring) is expected from the number classes in the Python. I.e. there should be __add__/sub/mul/pos/neg/pow/etc. But not __truediv__/floordiv.

      Even simpler idea: move the __eq__ method to the Number class.

      Then it would be impossible to instantiate a Number.

    9. rhettinger commented on May 15, 2021

      @rhettinger
      Contributor

      New changeset 3767401 by Miss Islington (bot) in branch '3.9':
      bpo-32133: Improve numbers docs (GH-26124) (GH-26147)
      3767401

    10. rhettinger commented on May 15, 2021

      @rhettinger
      Contributor

      New changeset a38db84 by Miss Islington (bot) in branch '3.10':
      bpo-32133: Improve numbers docs (GH-26124) (GH-26149)
      a38db84

    11. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.10 (EOL)3.113.9 (EOL)docseasytype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions