[Tutor] Have a very simple question
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 8 Aug 2002 12:27:56 +0100
> Why does 'doesn\'t' translate to "doesn't" ? This is in the Python
> tutorial but it doesn't say why this happens.
Coz \ means that the next character will be treated
literally. The next character is ' so Python does not
see it as the end of the string but as a character
within the string.
But its more usual to achieve the same effect
using different quotes:
>>>str1 = 'doesn\'t'
>>>str2 = "doesn't"
>>>str1 == str2 # should be true
1
>>>
HTH,
Alan g