[issue20686] Confusing statement about unicode strings in tutorial introduction

2020-05-31 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Python 2.7 is no longer supported. -- nosy: +serhiy.storchaka resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker ___

[issue20686] Confusing statement about unicode strings in tutorial introduction

2014-03-20 Thread Georg Brandl
Georg Brandl added the comment: First, entering a string at the command prompt like this is not considered "printing"; it's invoking the repr(). Then, when you say flexible, you say it as if it's a good thing. In this context "flexible" means as much as "easy to produce mojibake" and is not

[issue20686] Confusing statement about unicode strings in tutorial introduction

2014-03-20 Thread Daniel U. Thibault
Daniel U. Thibault added the comment: >>> mystring="äöü" >>> myustring=u"äöü" >>> mystring '\xc3\xa4\xc3\xb6\xc3\xbc' >>> myustring u'\xe4\xf6\xfc' >>> str(mystring) '\xc3\xa4\xc3\xb6\xc3\xbc' >>> str(myustring) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'asci

[issue20686] Confusing statement about unicode strings in tutorial introduction

2014-03-20 Thread R. David Murray
R. David Murray added the comment: re: file. You forgot the 'u' in front of the string: >>> f.write(u'This is a «test»\n') Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode character u'\xab' in position 10: ordinal not in range(128) So yo

[issue20686] Confusing statement

2014-03-20 Thread Daniel U. Thibault
Daniel U. Thibault added the comment: "The default encoding is normally set to ASCII [...]. When a Unicode string is printed, written to a file, or converted with str(), conversion takes place using this default encoding." >>> u"äöü" u'\xe4\xf6\xfc' Printing a Unicode string uses ASCII enco

[issue20686] Confusing statement

2014-02-20 Thread R. David Murray
R. David Murray added the comment: Thanks, yes, Georg already pointed out the issue with print. I suppose that this is something that changed at some point in Python2's history but this bit of the docs was not updated. Python can write anything to a file, you just have to tell it what encodin

[issue20686] Confusing statement

2014-02-20 Thread Daniel U. Thibault
Daniel U. Thibault added the comment: "It seems to me the statement is correct as written. What experiments indicate otherwise?" Here's a simple one: >>> print «1» The guillemets are certainly not ASCII (Unicode AB and BB, well outside ASCII's 7F upper limit) but are rendered as guillemets.

[issue20686] Confusing statement

2014-02-19 Thread Georg Brandl
Georg Brandl added the comment: The only problem I can see is that "print" uses the console encoding. For files and str(), the comment is correct for Python 2. -- nosy: +georg.brandl ___ Python tracker ___

[issue20686] Confusing statement

2014-02-19 Thread R. David Murray
R. David Murray added the comment: It seems to me the statement is correct as written. What experiments indicate otherwise? -- nosy: +r.david.murray ___ Python tracker ___

[issue20686] Confusing statement

2014-02-19 Thread Daniel U. Thibault
New submission from Daniel U. Thibault: Near the end of 3.1.3 http://docs.python.org/2/tutorial/introduction.html#unicode-strings you can read: "When a Unicode string is printed, written to a file, or converted with str(), conversion takes place using this default encoding." This can be inte