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


Groups > comp.lang.python > #40199

Re: raw format string in string format method?

X-Received by 10.224.213.197 with SMTP id gx5mr3613583qab.8.1362092805294; Thu, 28 Feb 2013 15:06:45 -0800 (PST)
X-Received by 10.49.75.195 with SMTP id e3mr1016121qew.24.1362092805247; Thu, 28 Feb 2013 15:06:45 -0800 (PST)
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.ripco.com!news.glorb.com!dd2no3891728qab.0!news-out.google.com!y6ni406qaj.0!nntp.google.com!dd2no3891722qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Thu, 28 Feb 2013 15:06:45 -0800 (PST)
In-Reply-To <512f6585$0$3108$ba620e4c@news.skynet.be>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=70.196.64.17; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj
NNTP-Posting-Host 70.196.64.17
References <512f6585$0$3108$ba620e4c@news.skynet.be>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <e466cd5b-e65f-458b-98bc-aa6379066038@googlegroups.com> (permalink)
Subject Re: raw format string in string format method?
From Rick Johnson <rantingrickjohnson@gmail.com>
Injection-Date Thu, 28 Feb 2013 23:06:45 +0000
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.lang.python:40199

Show key headers only | View raw


On Thursday, February 28, 2013 8:11:17 AM UTC-6, Helmut Jarausch wrote:
> Hi,
> 
> 
> 
> I'd like to print a string with the string format method which uses
> {0}, ...

/What/ uses "{0}" exactly? The substring you wish to inject or the format method? If the latter, we are aware of that!

> Unfortunately, the string contains TeX commands which use lots of
> braces. Therefore I would have to double all these braces just for the
> format method which makes the string hardly readable.

>>> "{0} balls".format("howdy{0} {doody}{10} had {wooden}")
'howdy{0} {doody}{10} had {wooden} balls'

But then why even bother to use the format method? Seriously, if you expect people to give a proper answer you need to not only explain the problem, but also, supply a simplified code example.

> Is there anything like a "raw" format string and any other means
> to circumvent this?

Even if there is, why would someone offer advice from such ambiguous input? Just because a "raw" format exists does not mean that /every/ poorly described problem will be solved using it.

Please provide adequate info.

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


Thread

raw format string in string format method? Helmut Jarausch <jarausch@skynet.be> - 2013-02-28 14:11 +0000
  Re: raw format string in string format method? Chris Angelico <rosuav@gmail.com> - 2013-03-01 01:22 +1100
    Re: raw format string in string format method? Helmut Jarausch <jarausch@skynet.be> - 2013-02-28 14:42 +0000
      Re: raw format string in string format method? Chris Angelico <rosuav@gmail.com> - 2013-03-01 02:09 +1100
      Re: raw format string in string format method? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-28 15:27 -0800
        Re: raw format string in string format method? Chris Angelico <rosuav@gmail.com> - 2013-03-01 15:29 +1100
      Re: raw format string in string format method? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-03-01 00:00 +0000
  Re: raw format string in string format method? Peter Otten <__peter__@web.de> - 2013-02-28 16:41 +0100
  Re: raw format string in string format method? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-28 15:06 -0800

csiph-web