Experiences/guidance on teaching Python as a first programming language

wxjmfauth at gmail.com wxjmfauth at gmail.com
Thu Dec 12 15:34:40 CET 2013


Le jeudi 12 décembre 2013 11:28:35 UTC+1, Chris Angelico a écrit :
> On Thu, Dec 12, 2013 at 8:17 PM,  <wxjmfauth at gmail.com> wrote:
> 
> > Windows, Py2.(7), ascii. It is not a secret Python uses
> 
> > ascii for the representation.
> 
> 
> 
> Actually no, it doesn't.
> 
> 
> 
> Python 2.7.4 (default, Apr  6 2013, 19:54:46) [MSC v.1500 32 bit
> 
> (Intel)] on win32
> 
> >>> s = "abcd\xa9"
> 
> >>> print(s)
> 
> abcd©
> 
> 
> 
> The copyright symbol is not in ASCII. Are you suggesting that Python
> 
> uses a 7-bit internal representation of this data? Because a quick
> 
> squiz at the source code will prove that wrong. This is not ASCII.
> 
> 

>>> sys.version
'2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)]'
>>> sys.stdout.encoding
'cp1252'
>>> s = 'abc\xa9'
>>> t = 'abc©'
>>> s
'abc\xa9'
>>> t
'abc\xa9'
>>> print s, t, (s, t)
abc© abc© ('abc\xa9', 'abc\xa9')
>>> def HumanStr(o):
	t = repr(o)
	newt = t.replace('\\xa9', '©')
	return newt

>>> print s, t, (s, t), HumanStr((s, t))
abc© abc© ('abc\xa9', 'abc\xa9') ('abc©', 'abc©')
>>> 

jmf

PS I do not insist on "sys.displayhook"

PS2 I can only congratulate this Turkish guy for
his understanding of Python



More information about the Python-list mailing list