Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99158
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Peter Otten <__peter__@web.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: String format - resolve placeholders names |
| Date | Fri, 20 Nov 2015 16:53:47 +0100 |
| Organization | None |
| Lines | 22 |
| Message-ID | <mailman.3.1448034840.2291.python-list@python.org> (permalink) |
| References | <20151120145227.GB13994@arxnet.hu> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | news.uni-berlin.de ev7GAZG5P9D4CxowRuqhhwWxSUe2yOE+5v1pTLo+pYIw== |
| Return-Path | <python-python-list@m.gmane.org> |
| 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; "'',": 0.07; 'none)': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'python': 0.10; "('',": 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'received:t-ipconnect.de': 0.16; 'result:': 0.16; 'subject:String': 0.16; 'wrote:': 0.16; 'string': 0.17; '>>>': 0.20; 'this:': 0.23; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'skip:s 30': 0.31; 'possible,': 0.35; 'item': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'names': 0.38; 'to:addr:python.org': 0.40; 'received:de': 0.40 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | p57bd871b.dip0.t-ipconnect.de |
| User-Agent | KNode/4.13.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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> |
| Xref | csiph.com comp.lang.python:99158 |
Show key headers only | View raw
Ervin Hegedüs wrote:
> Python has a good string formatter, eg. I can do this:
>
> s = "{who} likes {what}"
> d = {'who': "Adam", 'what': "ants"}
> s.format(**d)
>
> result:
> 'Adam likes ants'
>
> Is it possible, and if yes, how to resolve the placeholders names
> in string?
>>> import string
>>> for item in string.Formatter().parse("{who} likes {what}"):
... print(item)
...
('', 'who', '', None)
(' likes ', 'what', '', None)
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: String format - resolve placeholders names Peter Otten <__peter__@web.de> - 2015-11-20 16:53 +0100
Re: String format - resolve placeholders names Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-20 17:08 +0000
Re: String format - resolve placeholders names Ervin Hegedüs <airween@gmail.com> - 2015-11-20 20:36 +0100
csiph-web