On 05.05.15 21:19, Paul Moore wrote:
I want to write a string to an already-open file (sys.stdout, typically).
However, I *don't* want encoding errors, and the string could be arbitrary
Unicode (in theory). The best way I've found is
data = data.encode(file.encoding, errors='replace').dec
On Wed, May 6, 2015 at 4:19 AM, Paul Moore wrote:
> I want to write a string to an already-open file (sys.stdout, typically).
> However, I *don't* want encoding errors, and the string could be arbitrary
> Unicode (in theory). The best way I've found is
>
> data = data.encode(file.encoding,
Paul Moore :
> Nor can I - that's my point. But if all I have is an open text-mode
> file with the "strict" error mode, I have to incur one encode, and I
> have to make sure that no characters are passed to that encode which
> can't be encoded.
The file-like object you are given carries some bag
On 2015-05-05, Paul Moore wrote:
> I want to write a string to an already-open file (sys.stdout,
> typically). However, I *don't* want encoding errors, and the string
> could be arbitrary Unicode (in theory). The best way I've found is
>
> data = data.encode(file.encoding, errors='replace').de
On Tuesday, 5 May 2015 20:01:04 UTC+1, Dave Angel wrote:
> On 05/05/2015 02:19 PM, Paul Moore wrote:
>
> You need to specify that you're using Python 3.4 (or whichever) when
> starting a new thread.
Sorry. 2.6, 2.7, and 3.3+. It's for use in a cross-version library.
> If you're going to take c
On 05/05/2015 02:19 PM, Paul Moore wrote:
You need to specify that you're using Python 3.4 (or whichever) when
starting a new thread.
I want to write a string to an already-open file (sys.stdout, typically).
However, I *don't* want encoding errors, and the string could be arbitrary
Unicode
I want to write a string to an already-open file (sys.stdout, typically).
However, I *don't* want encoding errors, and the string could be arbitrary
Unicode (in theory). The best way I've found is
data = data.encode(file.encoding, errors='replace').decode(file.encoding)
file.write(data)