[issue39416] Document default numeric string formats
New submission from Karl O. Pinc <kop@karlpinc.com>: Seems sane to put _some_ restrictions on the string representations of the Numeric classes. This would be a change to the Python language specification. Suggestions made in a pull request. See the email thread: Subject: Documenting Python's float.__str__() https://mail.python.org/archives/list/python-dev@python.org/thread/FV22TKT3S... ---------- assignee: docs@python components: Documentation messages: 360442 nosy: docs@python, kop priority: normal severity: normal status: open title: Document default numeric string formats _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Change by Karl O. Pinc <kop@karlpinc.com>: ---------- keywords: +patch pull_requests: +17498 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18111 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Eric V. Smith <eric@trueblade.com> added the comment: Is the lack of this documentation causing some confusion somewhere? This isn't rhetorical, I'm genuinely curious what problem you're trying to solve. Is there any mainstream programming language where the basics of what you've laid out aren't true? It all seems pretty obvious to me. For example, I can't see anyone looking at this and saying "Ah, base 10. That's why it's producing the output I'm seeing." ---------- nosy: +eric.smith _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Karl O. Pinc <kop@karlpinc.com> added the comment: On Wed, 22 Jan 2020 06:09:41 +0000 "Eric V. Smith" <report@bugs.python.org> wrote:
Eric V. Smith <eric@trueblade.com> added the comment:
Is the lack of this documentation causing some confusion somewhere? This isn't rhetorical, I'm genuinely curious what problem you're trying to solve.
I'd say no, there's no real confusion anywhere. This started with a search for documentation on Python's default string representation for float. This accidentally wound up on the python-dev mailing list and became a more general discussion during which I suggested that some fundamentals are clear. This is pretty much just a follow-up to that discussion.
Is there any mainstream programming language where the basics of what you've laid out aren't true? It all seems pretty obvious to me. For example, I can't see anyone looking at this and saying "Ah, base 10. That's why it's producing the output I'm seeing."
Well, I just got done looking at YAML which has a lot of base-related syntax including base 60. :) The problem that would be solved is that it's easy to rely on the default Numeric output formats. Most output probably does not go through a formatter, although this may change now that f-strings are so easy. Anyway, this would guarantee "normal output" for numbers, even when switching between Python implementations. Likewise, immutability of value when round-tripping through a string is also obvious. But is still an important property. So if these properties are important then include them in the spec. That's what specs are for. (I could probably find some non-mainstream languages (scheme perhaps) that have specs which include similar documentation. You pretty have to have a formatter in compiled languages, so those won't specify a default. Anyway, it shouldn't matter what other language specs do.) I understand if nobody sees this as a real problem. And I don't want to stand up as a big proponent. I'll point out the argument here and let others decide. Regards, Karl <kop@karlpinc.com> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset c60394c7fc9cc09b16e9675a3eeb5844b6d8523f by kpinc in branch 'master': bpo-39416: Document some restrictions on the default string representations of numeric classes (GH-18111) https://github.com/python/cpython/commit/c60394c7fc9cc09b16e9675a3eeb5844b6d... ---------- nosy: +miss-islington _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +21802 pull_request: https://github.com/python/cpython/pull/22860 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +21803 pull_request: https://github.com/python/cpython/pull/22861 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset ec62b47ebc8f29007942c8e9f3f260af91ca58cb by Miss Skeleton (bot) in branch '3.9': [3.9] bpo-39416: Document some restrictions on the default string representations of numeric classes (GH-18111) (GH-22860) https://github.com/python/cpython/commit/ec62b47ebc8f29007942c8e9f3f260af91c... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 89fac4c3748aa7eb23d09922331e90a62ce782fd by Miss Skeleton (bot) in branch '3.8': [3.8] bpo-39416: Document some restrictions on the default string representations of numeric classes (GH-18111) (GH-22861) https://github.com/python/cpython/commit/89fac4c3748aa7eb23d09922331e90a62ce... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Éric Araujo <merwok@netwok.org> added the comment: Thanks for the patch! ---------- nosy: +eric.araujo resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: +Python 3.10, Python 3.8, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Change by Karl O. Pinc <kop@karlpinc.com>: ---------- pull_requests: +21809 pull_request: https://github.com/python/cpython/pull/22867 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset f8b1ccd63c94bcde1c15d56d24add89861b6ceee by kpinc in branch 'master': Fix bpo-39416: Change "Numeric" to lower case; an english word, not a class name (GH-22867) https://github.com/python/cpython/commit/f8b1ccd63c94bcde1c15d56d24add89861b... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +21810 pull_request: https://github.com/python/cpython/pull/22868 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +21811 pull_request: https://github.com/python/cpython/pull/22869 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
miss-islington <mariatta.wijaya+miss-islington@gmail.com> added the comment: New changeset 224ed378b9aadad9dbbd890064677433188aecd9 by Miss Skeleton (bot) in branch '3.9': Fix bpo-39416: Change "Numeric" to lower case; an english word, not a class name (GH-22867) https://github.com/python/cpython/commit/224ed378b9aadad9dbbd890064677433188... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
Éric Araujo <merwok@netwok.org> added the comment: New changeset aedc94b8e9d0f7700c665d8d1ba9c93df33e63a8 by Miss Islington (bot) in branch '3.8': [3.8] bpo-39416: change word case to not imply ABC (GH-22867) (GH-22869) https://github.com/python/cpython/commit/aedc94b8e9d0f7700c665d8d1ba9c93df33... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue39416> _______________________________________
participants (4)
-
Eric V. Smith -
Karl O. Pinc -
miss-islington -
Éric Araujo