Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82013
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!hq-usenetpeers.eweka.nl!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.017 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'string': 0.09; 'subject:string': 0.09; 'dict': 0.16; 'guys,': 0.16; 'mapping,': 0.16; 'tuple': 0.16; 'tuple.': 0.16; 'typeerror:': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'email addr:gmail.com>': 0.22; 'print': 0.22; 'error': 0.23; 'skip:% 10': 0.24; '>': 0.26; 'switch': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'am,': 0.29; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'getting': 0.31; 'that.': 0.31; '"",': 0.31; 'allows': 0.31; 'file': 0.32; 'this.': 0.32; '(most': 0.33; 'fri,': 0.33; 'received:google.com': 0.35; 'error.': 0.37; 'skip:& 10': 0.38; 'mapping': 0.38; 'to:addr :python-list': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'advanced': 0.63; 'more': 0.64; 'statement,': 0.68 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=uvzjNDXX/bJQ1IDoTXClTJJxOxoDrlF5P4MUIpNRQbM=; b=D28Jl27CALVQKjbxW+nkyW9pc2iqLpAvKfzV7Lsg3z4Tve63htsxfhgfANNT+JXF6u 4qfcbzsDDlElSUh4N4yOh9/LvvZYblWv414B+F5Q8hSBwo30+crkc6IpHjJViog1xfCi mCsIfqzxN1WwKl/THm3r9sVkQ3gHjCdDr1v97bpHlLS4CF/Joe85lcAuU3relzTVu5yD s983+aRbTCz5Z4K6InsYSrIJ/d2dGyXXyydMgb0qd5RMYb2e6j0V/zJm9ZVnSoo0Nd3S uw34R9ZZFHRpSuGliXLS996i7CUz0bOnxoLdCpaSHckFuvJ3AL1q6nQieBTeyRgD/+Eg qW8Q== |
| X-Received | by 10.70.130.225 with SMTP id oh1mr30837264pdb.147.1417803297322; Fri, 05 Dec 2014 10:14:57 -0800 (PST) |
| MIME-Version | 1.0 |
| In-Reply-To | <14b86f3a-7284-4e83-b5c0-1d41c86d80a7@googlegroups.com> |
| References | <14b86f3a-7284-4e83-b5c0-1d41c86d80a7@googlegroups.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Fri, 5 Dec 2014 11:14:17 -0700 |
| Subject | Re: concat string and dict in print statement |
| To | Python <python-list@python.org> |
| Content-Type | multipart/alternative; boundary=001a11c30e20e5fea205097c0dbd |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16634.1417803306.18130.python-list@python.org> (permalink) |
| Lines | 44 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1417803306 news.xs4all.nl 2894 [2001:888:2000:d::a6]:36126 |
| X-Complaints-To | abuse@xs4all.nl |
| X-Received-Body-CRC | 2754707265 |
| X-Received-Bytes | 5019 |
| Xref | csiph.com comp.lang.python:82013 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
On Fri, Dec 5, 2014 at 10:31 AM, <gaurangnshah@gmail.com> wrote:
>
> Hi Guys,
>
> I am trying to combine string and dict in the print statement, however
getting an error. Would someone let me know what will be correct way to do
that.
>
> stats={'lname': 'shah', 'fname': 'gaurang'}
> a=test
>
> print "%s %(fname)s %(lname)s" %(a,stats)
>
> Following is the error I am getting
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> TypeError: format requires a mapping
You need to use either a tuple or a mapping, not a mapping inside a tuple.
Or switch to using str.format, which allows more advanced attribute/item
look-ups like this.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
concat string and dict in print statement gaurangnshah@gmail.com - 2014-12-05 09:31 -0800 Re: concat string and dict in print statement Peter Otten <__peter__@web.de> - 2014-12-05 19:11 +0100 Re: concat string and dict in print statement Ian Kelly <ian.g.kelly@gmail.com> - 2014-12-05 11:14 -0700
csiph-web