Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #33265

Re: Error messages from format()

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <d@davea.name>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'string.': 0.04; 'builtin': 0.07; 'parameter': 0.07; 'subject:Error': 0.07; 'advice.': 0.09; 'formatted': 0.09; 'method:': 0.09; 'subject:()': 0.09; 'subject:messages': 0.09; 'cc:addr:python-list': 0.10; 'clear.': 0.16; 'curly': 0.16; 'sequence.': 0.16; 'str.format()': 0.16; 'wrote:': 0.17; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header :User-Agent:1': 0.26; 'object,': 0.27; 'dictionary': 0.29; 'function': 0.30; 'url:python': 0.32; 'docs': 0.33; 'list': 0.35; 'built-in': 0.35; 'sequence': 0.35; 'pm,': 0.35; 'url:org': 0.36; 'url:library': 0.36; 'subject:: ': 0.38; 'url:docs': 0.38; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'first': 0.61; 'url:%20': 0.63; 'more': 0.63; 'header:Reply-To:1': 0.68; 'received:74.208': 0.71; 'reply-to:no real name:2**0': 0.72; 'received:74.208.4.194': 0.84; 'url:functions': 0.84
Date Tue, 13 Nov 2012 16:18:07 -0500
From Dave Angel <d@davea.name>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121011 Thunderbird/16.0.1
MIME-Version 1.0
To "Colin J. Williams" <cjw@ncf.ca>
Subject Re: Error messages from format()
References <k7tnqp$4r2$1@theodyn.ncf.ca> <50a293a0$0$29999$c3e8da3$5496439d@news.astraweb.com> <k7uaak$mo4$1@theodyn.ncf.ca>
In-Reply-To <k7uaak$mo4$1@theodyn.ncf.ca>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-Provags-ID V02:K0:vWET/l8wQpusbu+TUv5WPg/y6v/WjZK/rvs2wWN4hwy XTLawprGIKDCToI3o2JRDnvqTKYDiDuSHB7Sq+a8u47njTuP54 fpXmcIYXA8nz13S7vXBvGYrHTYdXooyKo7cKvVpg+TYP8Ki6NX 9yMC3MugTUtSHLAnYnWLylG6TuNI6aeq1BHleCdaF40a5QRLHx Ytt0/YWFTIcvZKaW+NYqrm8eXb5kkmqyNHNFNb7xFJ4HhmBCPo xRewWvFQNTG05t/K+Xd7sFhEslbWtWMJnrnKnNy2oNLVwERe0g pbAxMyV4Hqa7cJ8RiygBDDQgOHlYDkHM7GaAfghPdlwVWIogQ= =
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To d@davea.name
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3645.1352841512.27098.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1352841512 news.xs4all.nl 6894 [2001:888:2000:d::a6]:49268
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:33265

Show key headers only | View raw


On 11/13/2012 03:24 PM, Colin J. Williams wrote:
> <SNIP>
>
> I am working on the assumption that the first argument of the format
> builtin function and be a sequence of values, which can be selected
> with {1:}, {2:}, {0:} etc.
>
> The docs don't make this clear.  I would appreciate advice.
>

The built-in function format():

http://docs.python.org/3.3/library/functions.html?highlight=format%20builtin#format

The first parameter is a single object, NOT a sequence.  One object, one
format.  If you want more generality, use the str.format() method:

http://docs.python.org/3.3/library/stdtypes.html?highlight=format#str.format

where you can supply a list or a dictionary of multiple items to be
formatted into a single string.  That's the one where you supply the
curly braces.


-- 

DaveA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Error messages from format() "Colin J. Williams" <cjw@ncf.ca> - 2012-11-13 10:08 -0500
  Re: Error messages from format() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-13 18:38 +0000
    Re: Error messages from format() "Colin J. Williams" <cjw@ncf.ca> - 2012-11-13 15:24 -0500
      Re: Error messages from format() Dave Angel <d@davea.name> - 2012-11-13 16:18 -0500
      Re: Error messages from format() Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-11-13 22:54 +0000

csiph-web