Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Stephen Hansen Newsgroups: comp.lang.python Subject: Re: Python Madlibs.py code and error message Date: Wed, 27 Apr 2016 23:50:46 -0700 Lines: 28 Message-ID: References: <3cff626c-28a2-499c-9877-de2df4d459d0@googlegroups.com> <6c0d96c5-c7f5-4659-a2e9-20f8d202d701@googlegroups.com> <1461820617.3238425.591942249.1484DAC3@webmail.messagingengine.com> <85fuu6jo1o.fsf@benfinney.id.au> <1461826246.3257796.591992793.54C5CC58@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de hZCnAT2jfy+241+sQHX0/gqo+0ohImtjXxevFYQDX7hQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'subject:Python': 0.05; 'formatting': 0.07; 'subject:code': 0.07; '"my': 0.09; 'positional': 0.09; 'received:internal': 0.09; 'python': 0.10; 'subject:error': 0.11; 'wed,': 0.15; 'argument': 0.15; '"bring': 0.16; '"first,': 0.16; '(ie,': 0.16; 'better:': 0.16; 'examples:': 0.16; 'formatting.': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'mismatch': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'shalt': 0.16; '{0}': 0.16; '{0}"': 0.16; '{name}"': 0.16; '{}"': 0.16; 'wrote:': 0.16; 'string': 0.17; '(not': 0.20; 'arguments': 0.22; 'stephen': 0.22; 'leave': 0.23; 'references': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'parameters': 0.27; 'implicitly': 0.29; "i'm": 0.30; 'url:python': 0.33; 'except': 0.34; 'url:org': 0.36; 'keyword': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'missing': 0.37; 'received:66': 0.38; 'means': 0.39; 'format': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'url:3': 0.60; 'header:Message-Id:1': 0.61; 'between': 0.65; '10:32': 0.84; 'url:string': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=ixokai.io; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=yz7N2s4sFfCH16lWy7V5+cQ4QuM=; b=cP3MG3 YtsOsr7R/HAmHTz9M4J5EelzOj1iU5luhzaK01rIXtPQqUn3sl0no0CIQjKAbnBl 6nS9bvP2ToyYwgmJd8FiD6Esi6G87tjOGH0vRQdMwYLK8QV+RLU8BlpEishdpHip F+hO2OmGvuwAYndXNHs/lnpWadvdoqrkTkgik= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=yz7N2s4sFfCH16l Wy7V5+cQ4QuM=; b=nWYFIKD6lCV9pvBiGRm4k73IGfFRGXaxOoU+2vpc5anXn17 kHadYqAOehXO6aUwVzGIKLhDCjvKPCx8rMXgROJkQVDy8qt6akpDgIx4X+ad+xPe 9y/sU7Ujtqzt1v2FWV7JUYh0/YoPAe+s1lcslGvaxp2AIRuOW1Db/FoXY+/E= X-Sasl-Enc: 5Kqle0YNAF9quX2oK25ABDZB8NfikhjHE2J6K0gcZCLN 1461826246 X-Mailer: MessagingEngine.com Webmail Interface - ajax-f1265324 In-Reply-To: <85fuu6jo1o.fsf@benfinney.id.au> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1461826246.3257796.591992793.54C5CC58@webmail.messagingengine.com> X-Mailman-Original-References: <3cff626c-28a2-499c-9877-de2df4d459d0@googlegroups.com> <6c0d96c5-c7f5-4659-a2e9-20f8d202d701@googlegroups.com> <1461820617.3238425.591942249.1484DAC3@webmail.messagingengine.com> <85fuu6jo1o.fsf@benfinney.id.au> Xref: csiph.com comp.lang.python:107764 On Wed, Apr 27, 2016, at 10:32 PM, Ben Finney wrote: > Stephen Hansen writes: >=20 > > The error message means there's a mismatch between the number of > > formatting instructions (ie, %s) and arguments passed to formatting. I > > leave it to you to count and find what's missing or extra, because I'm > > seriously not going to do that :) >=20 > Better: when you have many semantically-different values, use named (not > positional) parameters in the format string. >=20 > Some simple format string examples: >=20 > "First, thou shalt count to {0}" # References first positional > argument > "Bring me a {}" # Implicitly references the first > positional argument > "From {} to {}" # Same as "From {0} to {1}" > "My quest is {name}" # References keyword argument 'name' > [=E2=80=A6] >=20 > Except the poster is not using Python 3, so all of this is for naught.=20 --=20 Stephen Hansen m e @ i x o k a i . i o