On Thu, May 23, 2013 at 6:20 PM, Carlos Nepomuceno < carlosnepomuc...@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
-- http://mail.python.org/mailman/listinfo/python-list