[issue23460] Decimals do not obey ':g' exponential notation formatting rules

2019-02-11 Thread Tuomas Suutari
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 days, I

[issue23602] Implement __format__ for Fraction

2015-03-30 Thread Tuomas Suutari
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 another issue. Yes

[issue23602] Implement __format__ for Fraction

2015-03-29 Thread Tuomas Suutari
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 that I realized two new things

[issue23602] Implement __format__ for Fraction

2015-03-29 Thread Tuomas Suutari
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 the various formatting

[issue23602] Implement __format__ for Fraction

2015-03-09 Thread Tuomas Suutari
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 here. The _pydecimal

[issue23602] Implement __format__ for Fraction

2015-03-09 Thread Tuomas Suutari
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

[issue23602] Implement __format__ for Fraction

2015-03-08 Thread Tuomas Suutari
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. -- ___ Python tracker rep

[issue23602] Implement __format__ for Fraction

2015-03-08 Thread Tuomas Suutari
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 ignore the precision bug

[issue23602] Implement __format__ for Fraction

2015-03-08 Thread Tuomas Suutari
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

[issue23602] Implement __format__ for Fraction

2015-03-07 Thread Tuomas Suutari
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

[issue23602] Implement __format__ for Fraction

2015-03-07 Thread Tuomas Suutari
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 rep...@bugs.python.org

[issue23460] Decimals do not obey ':g' exponential notation formatting rules

2015-03-07 Thread Tuomas Suutari
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://bugs.python.org

[issue22154] ZipFile.open context manager support

2015-03-07 Thread Tuomas Suutari
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 rep