Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'win32': 0.03; 'parameters': 0.04; 'subject:PEP': 0.07; 'cc:addr:python-list': 0.11; 'python': 0.11; '23,': 0.16; 'str.format()': 0.16; 'tuple': 0.16; '{}"': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thu,': 0.19; '>>>': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '>>>': 0.24; 'cc:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'returned': 0.30; 'message-id:@mail.gmail.com': 0.30; 'sep': 0.31; 'received:209.85': 0.35; 'received:209.85.220': 0.35; 'received:google.com': 0.35; 'received:209': 0.37; 'skip:& 10': 0.38; 'pm,': 0.38; 'skip:p 20': 0.39; 'carlos': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=vZF8rbi01wDZ3rKWB17ylZl3T7o5iT2wc0ROD12X2qE=; b=e6NKLrJ7PwTf+3j5SvRzjVsbOl4mx4f+6rAfqxZmt5eGWxmurpIXr3c8Z3aJ4bFK0Y iqudUAb9Hd5LptBd/Tw+R8gJeYDev6V0kbD+Aav6A5bggl+0mnr0MgHQ+/erSGc9lUX5 +w8W2AES3wuABRr77MBJEz0qZ7IPdAW9ofyZ9sH3y6URbBhjqkBTMdHan0PXlmR2mQUC QzPTNepMHqIO1yKgMRDniShJpUnriH5MNMXUzP7SQiaZscbgEPFWIa8VwBcv/ZSp7ipJ 32xVAT8RpXHv2kjYzpkktZyj0cpLfZ0HVzhrZZyU5TlXvuuFfrY1S9KGwLWmyW6fxpwL 0pZw== MIME-Version: 1.0 X-Received: by 10.68.222.233 with SMTP id qp9mr15346192pbc.63.1369358274509; Thu, 23 May 2013 18:17:54 -0700 (PDT) In-Reply-To: References: <519c348a$0$6599$c3e8da3$5496439d@news.astraweb.com> <519C3D99.5040107@gmail.com> <519cdcff$0$6599$c3e8da3$5496439d@news.astraweb.com> <87eaaf24-df6a-4f6b-b873-16ca96c12e24@b2g2000yqe.googlegroups.com> <519E6327.8070204@davea.name> Date: Thu, 23 May 2013 21:17:54 -0400 Subject: Re: PEP 378: Format Specifier for Thousands Separator From: Jerry Hill To: Carlos Nepomuceno Content-Type: multipart/alternative; boundary=047d7b10d07985c03c04dd6c9103 Cc: "python-list@python.org" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 62 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369358277 news.xs4all.nl 15921 [2001:888:2000:d::a6]:56327 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:45858 --047d7b10d07985c03c04dd6c9103 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, May 23, 2013 at 6:20 PM, Carlos Nepomuceno < carlosnepomuceno@outlook.com> wrote: > Can str.format() do the following? > > f =3D '%d %d %d' > v =3D '1,2,3' > print f % eval(v) > =E2=80=8BSure: Python 3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)] on win32 >>> f =3D "{} {} {}" >>> v =3D "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.=E2=80=8B -- =E2=80=8B Jerry=E2=80=8B --047d7b10d07985c03c04dd6c9103 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
On Thu, May 23, 2013 at 6:20 PM, Carlos Nepomuceno <carlosnepomuceno@outlook.com> wrote:
=E2=80=8BSure:

Pyt= hon 3.2.2 (default, Sep=C2=A0 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)]= on win32
>>> f =3D "{} {} {}"
>>> v =3D "1,2,3&q= uot;
>>> print(f.format(*eval(v)))
1 2 3
>>>

The * unpacks the tuple returned from eval(), so that you get 3 separat= e parameters passed to format(), instead of the single tuple.=E2=80=8B
--
=E2=80=8B
Jerry=E2=80=8B

--047d7b10d07985c03c04dd6c9103--