Seungbeom Kim added the comment:
It looks like this change has not been applied to Python 2.7. Do we have any
chance of getting it to 2.7?
So I'm unsure if anyone is actually using alternate formatting.
The alternative form is my favorite, and I think that %#g should be the
default format
Terry J. Reedy added the comment:
New features only go in new versions.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
___
___
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
stage: patch review - resolved
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
___
___
Eric V. Smith added the comment:
I'm going to go ahead and close this. Alternate formatting was added to float
and complex. I think leaving this issue open just confuses whether or not that
support was added. I know I had to go back and double check.
Since decimal never participated in
Stefan Krah added the comment:
This might be out of date: _decimal has never implemented alternate
formatting and so far there have been no reported issues.
Another data point: Go apparently implements alternate formatting
only for octal, hex and strings:
http://golang.org/pkg/fmt/
So I'm
Raymond Hettinger added the comment:
So I'm unsure if anyone is actually using alternate formatting.
That makes sense. Any further effort should wait until there is known demand.
Otherwise, we risk growing the API with codes that aren't used.
--
resolution: - later
versions:
Changes by Mark Lawrence breamore...@yahoo.co.uk:
--
nosy: -BreamoreBoy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
___
___
Mark Lawrence added the comment:
@Eric looks as if the bulk of the work has been done so would you like to dot
the i's and cross the t's?
--
nosy: +BreamoreBoy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
Eric Smith e...@trueblade.com added the comment:
Checked in r86751. I'm leaving this open until I fix the remaining issue with
'#g' for Decimal.
--
components: +Library (Lib)
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
Changes by Eric Smith e...@trueblade.com:
--
stage: unit test needed - patch review
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
___
___
Changes by Eric Smith e...@trueblade.com:
Removed file: http://bugs.python.org/file19722/issue7094.diff
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7094
___
Eric Smith e...@trueblade.com added the comment:
Updated patch. I'm pretty happy with this one and will commit it after review.
--
Added file: http://bugs.python.org/file19753/issue7094.diff
___
Python tracker rep...@bugs.python.org
Mark Dickinson dicki...@gmail.com added the comment:
I haven't done a full review, but this looks good at first glance.
For '#g' formatting on the Decimal type, I wonder whether the patch gives the
right semantics. E.g., should
format(Decimal('1.23'), '#.6g')
give '1.23' or '1.23000'?
Mark Dickinson dicki...@gmail.com added the comment:
I think the change below is sufficient if we decide that the '#g' formatting
should always have the given number of significant digits.
--- Lib/decimal.py (revision 86635)
+++ Lib/decimal.py (working copy)
@@ -3701,7 +3701,8 @@
Mark Dickinson dicki...@gmail.com added the comment:
Gah. That doesn't work for zeros, though.
Apart from this, the rest of the patch looks good, and all tests pass on my
machine. (Well, except for test_urllib2_localnet, but I'm pretty sure that
failure is unrelated.)
I hadn't realized the
Eric Smith e...@trueblade.com added the comment:
I didn't realize it either, or I would have done this patch months ago. But of
course it's needed for %-formatting.
I'll consider the 'g' case and see what I come up with.
--
___
Python tracker
Eric Smith e...@trueblade.com added the comment:
I agree that:
format(Decimal('1.23'), '#.6g')
should give '1.23000', just as:
format(1.23, '#.6g')
does.
I'll work on fixing the patch, although if I don't get to it in the next few
days I'll commit the existing patch and open another
Eric Smith e...@trueblade.com added the comment:
Also note that if # is added for float and Decimal, it should be added for
complex. My Bug Day sprint group will have a patch for this shortly.
--
___
Python tracker rep...@bugs.python.org
Eric Smith e...@trueblade.com added the comment:
This is the patch developed today at the DCPython sprint. I have not reviewed
it very well. I know that at least:
- formatting is not consistent
- the docs need reviewing
- I want to add more tests
- Misc/NEWS and Misc/ACKS need updating
But I'm
Raymond Hettinger rhettin...@users.sourceforge.net added the comment:
I do not believe that this is covered by the moratorium. It's important for
3.x success to get new string formatting to its highest state of usability.
Matching published standards and practices(i.e. C99) and improving
Terry J. Reedy tjre...@udel.edu added the comment:
I believe this is covered by the PEP3003 3.2 change moratorium.
--
nosy: +terry.reedy
versions: +Python 3.3 -Python 2.7, Python 3.2
___
Python tracker rep...@bugs.python.org
Eric Smith e...@trueblade.com added the comment:
When and if this is implemented, there's a test in test_float.py that
needs to be deleted. Search on if not '#' in fmt:, added in r76632.
--
___
Python tracker rep...@bugs.python.org
New submission from Mark Dickinson dicki...@gmail.com:
Python's old-style formatting supports the use of an alternative form
(specified by including a '#' in the format) for 'e', 'f' and 'g'
formatting:
Python 3.2a0 (py3k:75275:75276, Oct 7 2009, 20:26:36)
[GCC 4.0.1 (Apple Inc. build
Eric Smith e...@trueblade.com added the comment:
I'm adding 2.7. Since 2.7 and 3.2 share the same code base, I'd rather
add it to both if we're going to do it at all.
--
assignee: - eric.smith
versions: +Python 2.7
___
Python tracker
Mark Dickinson dicki...@gmail.com added the comment:
Just for reference, the effect of the alternative style is explained
succinctly in the C99 standard (well, the N1256 draft, anyway):
For a, A, e, E, f, F, g, and G conversions, the result of converting a
floating-point number always
25 matches
Mail list logo