Printing a percent sign

Lawrence D'Oliveiro ldo at geek-central.gen.new_zealand
Tue Sep 26 06:34:24 EDT 2006


In message <1159263309.699677.301130 at m7g2000cwm.googlegroups.com>, John
Machin wrote:

> Lawrence D'Oliveiro wrote:
>> In message <1159230293.270822.50390 at d34g2000cwd.googlegroups.com>, John
>> Machin wrote:
>>
>> > 1. Reasoning: How do you get a literal "'" into an SQL string constant?
>> > How do you get a literal "\" into a Python string constant? How do you
>> > get a literal "$" into some *x shell command lines? Do you detect a
>> > pattern?
>>
>> None of which applies to escaping of % characters in format strings.
> 
> What I had in mind was:
> 
> where surname = 'O''REILLY'
> install_dir = "C:\\Python25"
> ...
> print "The interest rate is %.2f%% p.a." % (rate * 100.0)
> 
> the common pattern being that the problem character is doubled.

Which doesn't apply to the "$" character in *nix shell command lines.



More information about the Python-list mailing list