is there a problem on this simple code

Bengt Richter bokr at oz.net
Sun Mar 13 13:54:45 EST 2005


On Sun, 13 Mar 2005 10:46:52 -0500, Peter Hansen <peter at engcorp.com> wrote:

>Bengt Richter wrote:
>> Sorry for jumping in with a largely irrelevant comment. I didn't look
>> at the code, just sought to illustrate the 6/18 thing further, in a kneejerk reaction.
>> Though BTW FWIW the visual sequence of glyphs representing the data was more a str output
>> than repr, I guess:
>> 
>>  >>> repr("C\x01\x02\x10'\x83")
>>  '"C\\x01\\x02\\x10\'\\x83"'
>>  >>> str("C\x01\x02\x10'\x83")
>>  "C\x01\x02\x10'\x83"
>
>Actually, both of those have an additional repr() call
>courtesy of the Python interactive console.  The output
>of str() on that string is unprintable, but the above
>representation has already been repr()ed by Python for
>consumption by fragile hyoo-mans...
Ok,

 >>> print repr("C\x01\x02\x10'\x83")
 "C\x01\x02\x10'\x83"

But note that _no_ str-type string is printable at all until you assume
that it is an encoding identifying a glyph sequence and you (re)encode/interpret
for a device (virtual or not) that has a font and can present the font
information visually to your eyes (or via some modulation of sensible
environment for other senses) ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list