Re: raw format string in string format method?

Discussion in 'Python' started by Rick Johnson, Feb 28, 2013.

  1. Rick Johnson

    Rick Johnson Guest

    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.
    Rick Johnson, Feb 28, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ven
    Replies:
    6
    Views:
    512
  2. bharath
    Replies:
    4
    Views:
    3,153
    Thomas Fritsch
    Mar 16, 2007
  3. ankur
    Replies:
    1
    Views:
    12,737
    Jan =?UTF-8?B?VGhvbcOk?=
    Aug 27, 2007
  4. Chris Angelico
    Replies:
    3
    Views:
    150
    Mark Lawrence
    Mar 1, 2013
  5. Peter Otten
    Replies:
    0
    Views:
    130
    Peter Otten
    Feb 28, 2013
Loading...

Share This Page