O/S: Win2K
Vsn of Python: 2.4
Here is copy/paste from interactive window of pythonwin:
[color=blue][color=green][color=darkred]
>>> x = "Joe's desk"
>>> y = 'Joe\x92s desk'
>>> type(x)[/color][/color][/color]
<type 'str'>[color=blue][color=green][color=darkred]
>>> type(y)[/color][/color][/color]
<type 'str'>[color=blue][color=green][color=darkred]
>>> print x[/color][/color][/color]
Joe's desk[color=blue][color=green][color=darkred]
>>> print y[/color][/color][/color]
Joe's desk[color=blue][color=green][color=darkred]
>>> if x == y:[/color][/color][/color]
.... print 'equal'
.... else:
.... print 'not equal'
....
not equal[color=blue][color=green][color=darkred]
>>> len(x)[/color][/color][/color]
10[color=blue][color=green][color=darkred]
>>> len(y)[/color][/color][/color]
10[color=blue][color=green][color=darkred]
>>> ord(x[3])[/color][/color][/color]
39[color=blue][color=green][color=darkred]
>>> ord(y[3])[/color][/color][/color]
146[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
My questions are:
1) is the 'x' character within the variable y a signal that what
follows is a hex value?
2) is it more than just a coincidence that 146 (the result of
ord(y[3])) is the decimal equivalent of the hex number 92?
3) is there any character set in which 146 represents the
single-quote/apostrophe character? if so, which character set?
4) what is the role/function of the backslash character in the variable
y?
5) how did the print statement know to transform the contents of y
('Joe\x92s desk') to something that gets displayed as:
Joe's desk
?
6) Would it be correct to infer that the print statement is aware of
characters beyond the 128 characters in the ascii character set?
Vsn of Python: 2.4
Here is copy/paste from interactive window of pythonwin:
[color=blue][color=green][color=darkred]
>>> x = "Joe's desk"
>>> y = 'Joe\x92s desk'
>>> type(x)[/color][/color][/color]
<type 'str'>[color=blue][color=green][color=darkred]
>>> type(y)[/color][/color][/color]
<type 'str'>[color=blue][color=green][color=darkred]
>>> print x[/color][/color][/color]
Joe's desk[color=blue][color=green][color=darkred]
>>> print y[/color][/color][/color]
Joe's desk[color=blue][color=green][color=darkred]
>>> if x == y:[/color][/color][/color]
.... print 'equal'
.... else:
.... print 'not equal'
....
not equal[color=blue][color=green][color=darkred]
>>> len(x)[/color][/color][/color]
10[color=blue][color=green][color=darkred]
>>> len(y)[/color][/color][/color]
10[color=blue][color=green][color=darkred]
>>> ord(x[3])[/color][/color][/color]
39[color=blue][color=green][color=darkred]
>>> ord(y[3])[/color][/color][/color]
146[color=blue][color=green][color=darkred]
>>>[/color][/color][/color]
My questions are:
1) is the 'x' character within the variable y a signal that what
follows is a hex value?
2) is it more than just a coincidence that 146 (the result of
ord(y[3])) is the decimal equivalent of the hex number 92?
3) is there any character set in which 146 represents the
single-quote/apostrophe character? if so, which character set?
4) what is the role/function of the backslash character in the variable
y?
5) how did the print statement know to transform the contents of y
('Joe\x92s desk') to something that gets displayed as:
Joe's desk
?
6) Would it be correct to infer that the print statement is aware of
characters beyond the 128 characters in the ascii character set?
Comment