Tuomas Suutari added the comment:
> What is the status of this issue? I can submit a PR based on Tuomas Suutari's
> patch.
Don't know more about the status, but nobody seemed to care to take my
patch forward. If contributions are accepted as GitHub pull requests
these d
Tuomas Suutari added the comment:
On 30 March 2015 at 13:49, Stefan Krah wrote:
> Regarding Decimal:
>
> 1) The context precision isn't used for formatting. If you have
> another reason for proposing the optional context argument for
> dec_format(), please open
Tuomas Suutari added the comment:
On 29 March 2015 at 19:54, Serhiy Storchaka wrote:
> I think that Decimal is not needed for Fraction.__format__ (and I'm not sure
> that issue23602v4.patch is correct).
Of course it's not needed. I'm using it to avoid re-implementing all
t
Tuomas Suutari added the comment:
Thanks for the comments again!
I fixed the "format(F(4, 27), '.1f') -> 0.2" issue
Serhiy Storchaka reported. Fix for that was as simple as adding one to the
precision the decimals are calculated in, but while adding test cases for t
Tuomas Suutari added the comment:
Version 3 of the patch. Changes to v2:
* Use raw-strings for the regexps.
* Make the specifier regexp more robust with \A, \Z and re.DOTALL.
* Add more test cases; especially g and e formats and negative fractions.
--
Added file: http
Tuomas Suutari added the comment:
Martin Panter wrote:
> Regarding sharing fractions._parse_format_specifier(), perhaps have a look at
> _pydecimal._parse_format_specifier()
I did find that, but since it was a private function in private
module, I was unsure if I can use it her
Tuomas Suutari added the comment:
Here's the next round of the patch.
For formatting fractions with any given precision I had to parse the precision
from format specifier and at this point it seemed easier to just create a
general parser for the Format Specification Mini-Language. In
Tuomas Suutari added the comment:
Eric V. Smith wrote:
> I'm not sure it needs fixing: it follows from the definition of using
> Decimal(num) / Decimal(denom). Plus, it's controllable with a decimal context:
Hmm... Even though it's tempting to agree with you and just ign
Tuomas Suutari added the comment:
Serhiy Storchaka wrote:
>>>> from fractions import Fraction as F
>>>> format(F(1, 3), '.30f')
> '0.00'
Good catch! I'll try to fix this and add some more test cases.
--
__
Tuomas Suutari added the comment:
Here's a patch that adds Fraction.__format__ implementation, test cases and
documentation.
--
keywords: +patch
Added file: http://bugs.python.org/file38378/issue23602.patch
___
Python tracker
New submission from Tuomas Suutari:
Since Decimal supports __format__, it would be nice that Fraction did too.
--
components: Library (Lib)
messages: 237460
nosy: tuomas.suutari
priority: normal
severity: normal
status: open
title: Implement __format__ for Fraction
versions: Python 3.5
Tuomas Suutari added the comment:
Here's a patch that fixes the description for 'g' to explain what happens for
`Decimal` and also documents the Decimal.__format__ in the documentation of the
decimal module.
--
keywords: +patch
nosy: +Tuomas Suutari
Added file: http://
Tuomas Suutari added the comment:
The context manager support was added on issue #5511, so the documentation
should go to 2.7, 3.4 and default. Also the version added notes should be added.
--
nosy: +Tuomas Suutari
___
Python tracker
<h
13 matches
Mail list logo