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


Groups > comp.lang.python > #79916

Re: %%(%s)s mean in python

X-FeedAbuse http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63
Path csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!news.muarf.org!news.roellig-ltd.de!news.babsi.de!open-news-network.org!news2.open-news-network.org!.POSTED!not-for-mail
From Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de>
Newsgroups comp.lang.python
Subject Re: %%(%s)s mean in python
Date Wed, 29 Oct 2014 16:12:44 +0100
Organization A not so newly installed InterNetNews server
Lines 22
Message-ID <m2r05g$5hm$1@r01.glglgl.de> (permalink)
References <76c6409c-5289-4cf2-b80a-6349325356c6@googlegroups.com>
NNTP-Posting-Host 2001:41d0:8:4cbf:25:5e92:1e80:90b
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news2.open-news-network.org 1414596002 18961 2001:41d0:8:4cbf:25:5e92:1e80:90b (29 Oct 2014 15:20:02 GMT)
X-Complaints-To abuse@open-news-network.org
NNTP-Posting-Date Wed, 29 Oct 2014 15:20:02 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 Hamster/2.1.0.11
In-Reply-To <76c6409c-5289-4cf2-b80a-6349325356c6@googlegroups.com>
Xref csiph.com comp.lang.python:79916

Show key headers only | View raw


Am 29.10.2014 07:02 schrieb satishmlmlml@gmail.com:

> What does %%(%s)s mean in Python?

Weird question, as this has nothing to do with the code you just posted.

In general, what comes up to my mind, is that it is a format string to 
build another format string.

Example:

metafmt = '%%(%s)s'
fieldname = 'myfield'
fmt = metafmt % fieldname
# Now we have a fmt as if it was assigned with '%(myfield)s':
# %% -> %, %s -> myfield.

d = {fieldname: 'my content'}

print fmt % d
# this now prints the given field - which is noted in fieldname -
# from the given dict d.

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


Thread

%%(%s)s mean in python satishmlmlml@gmail.com - 2014-10-28 23:02 -0700
  Re: %%(%s)s mean in python satishmlmlml@gmail.com - 2014-10-28 23:12 -0700
  Re: %%(%s)s mean in python Ned Batchelder <ned@nedbatchelder.com> - 2014-10-29 07:38 -0400
  Re: %%(%s)s mean in python Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2014-10-29 16:12 +0100

csiph-web