print a vs print '%s' % a vs print '%f' a

David Cournapeau cournape at
Tue Dec 30 04:35:45 CET 2008

On Tue, Dec 30, 2008 at 12:23 PM, James Mills
<prologic at> wrote:
> On Tue, Dec 30, 2008 at 1:19 PM, David Cournapeau <cournape at> wrote:
> (... snip ...)
>> print '%f' % a # -> print '1.#INF'
> Would this not be controlled by:
> 1. float(a) or a.__float__()
> 2. tp_print

Bah, I made a mistake in my example: complex('inf') should read
float('inf') (complex('inf') does not work). So 1 is out :)

If I read correctly the code, tp_print also calls the format_float
function (as tp_str, and tp_repr), so it looks like it is not used in
that case.



More information about the Python-list mailing list