Re: Very stupid question about a % symbol

2010-09-17 Thread Xavier Ho
On 17 September 2010 12:48, Terry Reedy wrote: > Doubling an escape char, whatever it is, is a common convention: > >>> print("Print a {{}} format string line this: {{{}}}".format(2)) > Print a {} format string line this: {2} > Wow. That's convoluted. Took me a minute to process. Cheers, Xav --

Re: Very stupid question about a % symbol

2010-09-17 Thread Steven D'Aprano
On Thu, 16 Sep 2010 11:25:06 -0400, J wrote: > OK, this is a very stupid question about a very simple topic, but Google > is failing me this morning... [...] Others have already answered your question, but for future reference, many people won't bother to read posts with a meaningless subject li

Re: Very stupid question about a % symbol

2010-09-16 Thread Terry Reedy
On 9/16/2010 12:23 PM, J wrote: Thanks for the replies... I KNEW there was a simple way to escape the % but I had no idea what it was (I just had conviction). I was thrown when the \ didn't escape it... never knew about %%. But now I do! Thanks for the replies! Doubling an escape char, what

Re: Very stupid question about a % symbol

2010-09-16 Thread Jason Swails
Ha, I had this same problem, but I was trying to do dynamic formatting: ("%%%s" % format) % number where "format" is a python-ized fortran format string (i.e. "9.4E"). Looks kinda weird and less elegant than the {0:{1}}-type .format() syntax, but at least it preserves backwards compatibility to

Re: Very stupid question about a % symbol

2010-09-16 Thread J
On Thu, Sep 16, 2010 at 12:09, Grant Edwards wrote: > On 2010-09-16, J wrote: > >> Reported memory amounts are within 10% tolerance > "Reported memory amounts are within %d%% tolerance" % 10 > 'Reported memory amounts are within 10% tolerance' Thanks for the replies... I KNEW there was a si

Re: Very stupid question about a % symbol

2010-09-16 Thread Tim Chase
On 09/16/10 10:25, J wrote: OK, this is a very stupid question about a very simple topic, but print "Reported memory amounts are within %s%s tolerance" % (self.mem_tolerance,'%') Is there a better way to print a '%' in the string when also using formating? I've tried things like this: print "b

Re: Very stupid question about a % symbol

2010-09-16 Thread Grant Edwards
On 2010-09-16, J wrote: > Reported memory amounts are within 10% tolerance >>> "Reported memory amounts are within %d%% tolerance" % 10 'Reported memory amounts are within 10% tolerance' -- Grant Edwards grant.b.edwardsYow! It's the RINSE CYCLE!!

Re: Very stupid question about a % symbol

2010-09-16 Thread Xavier Ho
On 17 September 2010 01:25, J wrote: > Is there a better way to print a '%' in the string when also using > formating? > I believe %% will escape the % and prints it straight out. Cheers, Xav -- http://mail.python.org/mailman/listinfo/python-list

Very stupid question about a % symbol

2010-09-16 Thread J
OK, this is a very stupid question about a very simple topic, but Google is failing me this morning... I'm trying to print a string that looks like this: Reported memory amounts are within 10% tolerance and the print line looks (for now) like this: print "Reported memory amounts are within %s%s