| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
@serhiy-storchaka @ericvsmith Would either of you be interested in reviewing? |
Sorry, something went wrong.
|
float.__format__ does not support d. On other hand, %d in printf-like formatting accept float, but truncate it. Would not it cause confusion? Users may (wrongly) suppose that the d format specifier always format a number as a decimal integer. |
Sorry, something went wrong.
There was a problem hiding this comment.
It is perhaps out of the scope of this PR or this issue, but it may be useful to provide options for:
Sorry, something went wrong.
|
@serhiy-storchaka Thank you for reviewing!
Hmm, possibly. Now that I look at it, we're adding two ways to do exactly the same thing (that is, format(f, s) and format(f, s + 'd') do exactly the same thing where s is a format specifier without a presentation type). That seems unnecessary. What do you think about simply dropping the d support for now? So for example format(f, '>.10') would still work but format(f, '>.10d') wouldn't. Then we can still add support for a d presentation type in the future if that looks useful.
Yes, I think I'd rather leave these to a separate PR. |
Sorry, something went wrong.
Looks fine to me. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
Actually, I think I'd require the "d", just in case we want to do somethings else entirely without it. But I don't feel strongly about it. OTOH, note that for ints, the 'd' has no effect. |
Sorry, something went wrong.
|
@mdickinson It LGTM if drop 'd' and "integer-like". |
Sorry, something went wrong.
|
Thanks @serhiy-storchaka and @ericvsmith for feedback.
Yes, I can see a case both ways, and part of me wants to require a presentation type for all non-trivial formatting. I think this is close enough to the obvious one way to do formatting for Fractions that I'm happy for it to be the "default" formatting, so not require a "d". I'll make that change. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM. Thanks, Mark!
Sorry, something went wrong.
https://build.opensuse.org/request/show/1140281 by user dirkmueller + anag+factory - update to 1.16: * Formatting support was improved, following CPython 3.13a3 as of python/cpython#111320 * Add support for Python 3.13 by using Cython 3.0.8 and calling math.gcd().
https://build.opensuse.org/request/show/1140281 by user dirkmueller + anag+factory - update to 1.16: * Formatting support was improved, following CPython 3.13a3 as of python/cpython#111320 * Add support for Python 3.13 by using Cython 3.0.8 and calling math.gcd().
https://build.opensuse.org/request/show/1140281 by user dirkmueller + anag+factory - update to 1.16: * Formatting support was improved, following CPython 3.13a3 as of python/cpython#111320 * Add support for Python 3.13 by using Cython 3.0.8 and calling math.gcd().
PR python#100161 added fancy float-style formatting for the Fraction type, but left us in a state where basic formatting for fractions (alignment, fill, minimum width, thousands separators) still wasn't supported. This PR adds that support. --------- Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
PR python#100161 added fancy float-style formatting for the Fraction type, but left us in a state where basic formatting for fractions (alignment, fill, minimum width, thousands separators) still wasn't supported. This PR adds that support. --------- Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
| Back | FazBrowse Home | New Git URL |
PR #100161 added fancy float-style formatting for the Fraction type, but left us in a state where basic formatting for fractions (alignment, fill, thousands separators) still wasn't supported. For example, we can't currently specify a minimum width for a formatted fraction:
This PR adds that basic formatting support, aiming for compatibility with int formatting. The basic formatting is active either with presentation type d, or with no explicit presentation type. For example, on this branch:
All of the above except f"{y}" currently give ValueError on main.
Some details:
Pinging @ericvsmith for awareness.
📚 Documentation preview 📚: https://cpython-previews--111320.org.readthedocs.build/