PEP 378: Format Specifier for Thousands Separator
Carlos Nepomuceno
carlosnepomuceno at outlook.com
Thu May 23 21:41:22 EDT 2013
Thank you! Hail Eris!!! :)
________________________________
> Date: Thu, 23 May 2013 21:17:54 -0400
> Subject: Re: PEP 378: Format Specifier for Thousands Separator
> From: malaclypse2 at gmail.com
> To: carlosnepomuceno at outlook.com
> CC: python-list at python.org
>
> On Thu, May 23, 2013 at 6:20 PM, Carlos Nepomuceno
> <carlosnepomuceno at outlook.com<mailto:carlosnepomuceno at outlook.com>>
> wrote:
> Can str.format() do the following?
>
> f = '%d %d %d'
> v = '1,2,3'
> print f % eval(v)
>
> Sure:
>
> Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit
> (Intel)] on win32
> >>> f = "{} {} {}"
> >>> v = "1,2,3"
> >>> print(f.format(*eval(v)))
> 1 2 3
> >>>
>
> The * unpacks the tuple returned from eval(), so that you get 3
> separate parameters passed to format(), instead of the single tuple.
>
> --
>
> Jerry
>
More information about the Python-list
mailing list