Reading through "Learn Python the Hard Way", I have tried to modify exercise 6, in order to see what happens. Originally it contains:
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)
print "I said: %r." % x
print "I also said: '%s'." % y
and produces the output:
I said: 'There are 10 types of people.'.
I also said: 'Those who know binary and those who don't.'.
In order to see the differences between using %s and %r in the last line, I replaced it with:
print "I also said: %r." % y
and obtained now the output:
I said: 'There are 10 types of people.'.
I also said: "Those who know binary and those who don't.".
My question is: Why now there are the double quotes instead of the single quotes?