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

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Thu May 15 17:41:42 2003


On Thu, 15 May 2003, Rick Pasotto wrote:

> 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, '&&'). :-)


Hi Rick,


Right.  Percent signs.  Of course.  *sheepish grin* Doh.


My apologies for doing one thing and saying another.  Thanks for the
correction!