[Tutor] Re: How to leave literal %s in output of formatted string

Rick Pasotto rick@niof.net
Thu May 15 13:52:13 2003


On Thu, May 15, 2003 at 10:33:41AM -0700, Danny Yoo wrote:
> 
> 
> On Thu, 15 May 2003, Jeff Kowalczyk wrote:
> 
> > Good point, the direct subsitution will do the trick
> >
> > >>> s = '%s download %s' % (VendorID, '%s')
> >
> > If anyone knows, I'm still curious to know if there is an escape
> > character for %, for more complex cases that may come up in the future.
> 
> Hi Jeff,
> 
> To make a '%' stick around after a string formatting operation, we need a
> way of "escaping" that character.  The escape character was arbitrarily
> chosen to be two ampersands in a row:

I think two 'percent' signs (ie, '%%') would work better than two 'and'
signs (ie, '&&'). :-)

-- 
"Paper has a genius for multiplication that cannot be equaled anywhere
else in nature." -- Hugh Keenleyside
    Rick Pasotto    rick@niof.net    http://www.niof.net