[issue2110] Implement __format__ for Decimal

2009-03-17 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Mark, this looks fine.

Can you add support for PEP 378?

--
assignee: rhettinger - marketdickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

New version of decimal_n_format.patch, with support for the thousands 
separator (PEP 378).  As discussed on python-dev, during zero-padding the 
patched code adds an extra '0' on the left to avoid a leading ',' if 
necessary.  For example:

 format(Decimal('123456'), '08,')
'0,123,456'

The Decimal.__format__ method (and support code) had to be fairly 
significantly reworked.  However, I'm reasonably confident that this code 
is correct:  a patch review would be welcome if anyone has the time;  
otherwise I'll commit this in a couple of days or so.

--
stage:  - commit review
type:  - behavior
Added file: http://bugs.python.org/file13353/decimal_n_format2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-17 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

The tests you submitted are reassuring.  I think you should go ahead and
commit this.

--
resolution:  - accepted

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-17 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Committed, r70439 and r70440.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-13 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Here's a patch to implement the 'n' format specifier for Decimals
(see also issue 5481).

Raymond, could you give this a sanity check?

--
assignee: marketdickinson - rhettinger
Added file: http://bugs.python.org/file13324/decimal_n_format.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-13 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
resolution: accepted - 

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-13 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Sure, I will take a look.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2009-03-12 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Adding support for the 'n' format specifier should be done before 3.1 goes 
out.

--
priority: high - critical
versions: +Python 2.7, Python 3.1 -Python 2.6, Python 3.0

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2008-12-05 Thread Mark Dickinson

Changes by Mark Dickinson [EMAIL PROTECTED]:


--
priority:  - high

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2008-06-20 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

Reopening this;  I'd like to have a second go at implementing the 'n'
format specifier for the Decimal type.

See issue 2802 for hints about how to go about this.

--
assignee: facundobatista - marketdickinson

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2008-06-20 Thread Benjamin Peterson

Changes by Benjamin Peterson [EMAIL PROTECTED]:


--
status: closed - open

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2110
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2008-02-24 Thread Mark Dickinson

Mark Dickinson added the comment:

Here's a first attempt at Decimal.__format__; the patch is against the 
trunk, and should be forward ported as usual to 3.0, with obvious minor 
changes related to str/unicode.  It still needs some cleanup and some 
more tests, but I'm posting it now in the hope of getting some feedback.

I'm adding Raymond Hettinger and Eric Smith to the nosy list in case 
they want to comment.

Some points of interest:

 * I decided to make plain 'e', 'f' and 'g' formats (without an explicit 
precision) do no rounding:  they return a string that captures the exact 
value of the Decimal instance (though it can lose information about 
significant zeros).  So format(x, 'e') is basically a way to say 'give 
me str(x), but always include an exponent', and format(x, 'f') gives a 
way to print the value without ever including an exponent.  format(x, 
'g') is identical to str(x), except that it always uses the character 
'e' for an exponent (instead of using 'e' or 'E' depending on the 
context).

There are other possible options here (have a default precision;  use 
the precision from the context), but this one seemed to make most sense.  
I'd appreciate opinions.

 * the integer format specifiers are not supported.  After noticing that
the integer format specifiers aren't supported for floats either, I 
think this is the right thing to do.

 * the 'n' format specifier is not supported either;  it's supposed to 
use the current locale.  I can't find any easy way to do this---it seems 
as though the only real option is to manually fix the decimal point 
character, figure out where to place thousands separators, etc.  This 
would add quite a lot of not-really-Decimal-related code to decimal.py, 
and I'm reluctant to do that.  The right solution probably involves 
writing some support code and putting it somewhere else in the std. lib.

 * on the subject of not-really-Decimal-related code, it would be great
if the parse_format_specifier and format_align functions (near the end 
of decimal.py) could be moved somewhere else.  I'm planning to reuse 
these functions for Fraction.__format__.

--
keywords: +patch
nosy: +eric.smith, rhettinger
versions: +Python 2.6
Added file: http://bugs.python.org/file9539/decimal_format.patch

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2110
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2110] Implement __format__ for Decimal

2008-02-14 Thread Mark Dickinson

Mark Dickinson added the comment:

I can take a look at this if you like.  But I don't want to spoil your fun 
:)

--
nosy: +marketdickinson

__
Tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2110
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com