On 8/9/07, Eric V. Smith <[EMAIL PROTECTED]> wrote:

> If you want:
>
> x = 3
> "{0:f}".format(x)
>
> then be explicit and write:
>
> "{0:f}".format(float(x))

Because then you can't really create formatting strings.  Instead of

    >>> print("The high temperature at {place:s}, on {date:YYYY-MM-DD}
was {temp:f}" % tempsdict)
    >>> print("{name} scored {score:f}" % locals())

You would have to write

    >>> _tempsdict_copy = dict(tempsdict)
    >>> _tempsdict_copy['place'] = str(_tempsdict_copy['place'])
    >>> _tempsdict_copy['date'] =
    ...         datetime.date(_tempsdict_copy['date']).isoformat()
    >>> _tempsdict_copy['temp'] = float(_tempsdict_copy['temp'])
    >>> print("The high temperature at {place}, on {date} was {temp}"
% _tempsdict_copy)

    >>> _f_score = float(score)
    >>> print("{name} scored {score}" % locals())

-jJ
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to