[Python-3000] Need Decimal.__format__
Guido van Rossum
guido at python.org
Fri Aug 31 04:07:46 CEST 2007
On 8/30/07, Eric Smith <eric+python-dev at trueblade.com> wrote:
> Talin wrote:
> > I'm looking for a volunteer who understands the Decimal class well
> > enough to write a __format__ method for it. It should handle all of the
> > same format specifiers as float.__format__, but it should not use the
> > same implementation as float (so as to preserve accuracy.)
>
> If no one else steps up, I can look at it. But I doubt I can finish it
> by a1.
No, that's not Talin's point: we're not expecting this in a1, but a2
would be good.
> > Also, I'm interested in suggestions as to any other standard types that
> > ought to have a __format__ method, other than the obvious Date/Time
> > classes. What kinds of things do people usually want to print?
>
> I can do datetime.datetime and datetime.date, if no one else already
> has. I think they're just aliases for strftime. Is there any problem
> with re-using the C implemenation exactly?
>
> static PyMethodDef date_methods[] = {
> ...
> {"strftime", (PyCFunction)date_strftime, METH_VARARGS | METH_KEYWORDS,
> PyDoc_STR("format -> strftime() style string.")},
> {"__format__", (PyCFunction)date_strftime, METH_VARARGS | METH_KEYWORDS,
> PyDoc_STR("Alias for strftime.")},
>
> ...
>
> I just want to make sure there's no requirement that the function
> pointer be unique within the array, or anything like that.
>
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list