Re: Character Encodings and display of strings

2006-11-14 Thread Martin Miller
It is possible derive your own string class from the built-in one and override what 'repr' does (and make it do whatever you want). Here's an example of what I mean: # Sample # # -*- coding: iso-8859-1 -*- # Special string class to override the default # representation method. Main purpo

Re: Character Encodings and display of strings

2006-11-13 Thread Leo Kislov
JKPeck wrote: > It seemed to me that this sentence > > For many types, this function makes an attempt to return a string that > would yield an object with the same value when passed to eval(). > > might mean that the encoding setting of the source file might influence > how repr represented the co

Re: Character Encodings and display of strings

2006-11-13 Thread JKPeck
It seemed to me that this sentence For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval(). might mean that the encoding setting of the source file might influence how repr represented the contents of the string. Noth

Re: Character Encodings and display of strings

2006-11-13 Thread Diez B. Roggisch
JKPeck wrote: > Thanks for the quick answer. I thought repr was involved here, but > when I use repr explicitly I get a notation where the backslashes are > escaped. I also though that with the encoding explictily declared in > the source, that repr would take that into account and use the > cha

Re: Character Encodings and display of strings

2006-11-13 Thread JKPeck
Thanks for the quick answer. I thought repr was involved here, but when I use repr explicitly I get a notation where the backslashes are escaped. I also though that with the encoding explictily declared in the source, that repr would take that into account and use the character form, but obviousl

Re: Character Encodings and display of strings

2006-11-13 Thread Fredrik Lundh
"JKPeck" wrote: >I am trying to understand why, with nonwestern strings, I sometimes get > a hex display and sometimes get the string printed as characters. > > With my Python locale set to Japanese and with or without a # coding of > cp932 (this is Windows) at the top of the file, I read a list o

Character Encodings and display of strings

2006-11-13 Thread JKPeck
I am trying to understand why, with nonwestern strings, I sometimes get a hex display and sometimes get the string printed as characters. With my Python locale set to Japanese and with or without a # coding of cp932 (this is Windows) at the top of the file, I read a list of Japanese strings into a