[EMAIL PROTECTED] wrote: > >O/S: Win2K >Vsn of Python: 2.4 > >Here is copy/paste from interactive window of pythonwin: >... >My questions are: >1) is the 'x' character within the variable y a signal that what >follows is a hex value?
Sort of; it is the \x pair that signals this. This is in the Python documentation; the convention was borrowed from C. >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? Did you really have to ask that question? The 4th character of Y is a byte containing 0x92, which is 146 in decimal. >3) is there any character set in which 146 represents the >single-quote/apostrophe character? if so, which character set? Certainly. The default Windows code page, CP 1252, is an extension to ISO-8859-1 which includes this. It defines 0x91 as a "left single quote" and 0x92 as a "right single quote". In typography, you often want to use different quotes for something like 'this' than you do for something like isn't. 0x91 and 0x92 are used for 'this', and 0x27 is used for isn't. Your VGA font happens to display "left single quote" and "right single quote" with the same glyph as "apostrophe". >4) what is the role/function of the backslash character in the variable >y? See above. \x introduces a hex character. \047 is another special sequence; this is the octal code for apostrophe. >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 >? The print statement didn't know that. It sent the 0x92 character. It's just that your VGA font happens to display them as the same glyph. >6) Would it be correct to infer that the print statement is aware of >characters beyond the 128 characters in the ascii character set? Certainly. It knows about whatever the current character set is. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list