Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76549 > unrolled thread
| Started by | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| First post | 2014-08-19 05:03 -0400 |
| Last post | 2014-08-19 05:03 -0400 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python 2.7 IDLE Win32 interactive, pasted characters i- wrong encoding Terry Reedy <tjreedy@udel.edu> - 2014-08-19 05:03 -0400
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Date | 2014-08-19 05:03 -0400 |
| Subject | Re: Python 2.7 IDLE Win32 interactive, pasted characters i- wrong encoding |
| Message-ID | <mailman.13137.1408439077.18130.python-list@python.org> |
On 8/18/2014 7:44 PM, Chris Angelico wrote: > Python 3 works fine, at least for BMP characters: > > Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 > 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. >>>> u"U+20AC is € is 0x80 in CP-1252" > 'U+20AC is € is 0x80 in CP-1252' >>>> ascii(_) > "'U+20AC is \\u20ac is 0x80 in CP-1252'" > > Python 2 doesn't: > > Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. >>>> # -*- coding: utf-8 -*- I don't think this has any lasting effect in interactive mode. Each statement is compiled and executed separatedly. In Idle, this is done with exec(). >>>> u"U+20AC is € is 0x80 in CP-1252" > u'U+20AC is \x80 is 0x80 in CP-1252' Better than what I get on my 3.4.1 Win7 U+20AC is is 0x80 in CP-1252 > The pasted-in character is encoded CP-1252 instead of being a Unicode > literal. Beginning the session with the coding cookie doesn't make any > difference; nor does the Options|Configure IDLE, General tab, Default > Source Encoding, which I have set to UTF-8. My suspicion is that both > of these will work for editing files, but not for interactive > execution. # -*- coding: utf-8 -*- print(u"U+20AC is € is 0x80 in CP-1252") works > Poking around led me to this: > http://bugs.python.org/issue4454 > which pointed me to > http://bugs.python.org/issue4008 > but (a) that claims to have been fixed in Jan 2009 (I first noticed > this issue in 2.7.4 dated 2013, and then I updated to 2.7.8 in case it > had been fixed), and (b) it seems to be talking about the editor, not > the interactive interpreter. > > How do I get IDLE to accept Unicode in literals? The problem is python exec, not Idle. Use the editor and submit coding and code together. -- Terry Jan Reedy
Back to top | Article view | comp.lang.python
csiph-web