Terry Reedy writes:
> On 10/6/2015 6:45 AM, Ben Finney wrote:
> > Ben Finney writes:
>
> > How can I convince ‘print’, everywhere throughout a module, that it
> > should coerce its arguments using ‘unicode’?
>
> Use Python 3. I am only half joking. Switching to unicode instead
> of bytes as t
Peter Otten <__pete...@web.de> writes:
> Have a look at PyFile_WriteObject in Objects/fileobject.c.
> As I understand the code it basically does
>
> if isinstance(obj) and stream.encoding is not None:
> s = obj.encode(stream.encoding))
> else:
> s = str(obj)
> stream.write(s)
So as I unde
On 10/6/2015 6:45 AM, Ben Finney wrote:
Ben Finney writes:
How can I convince ‘print’, everywhere throughout a module, that it
should coerce its arguments using ‘unicode’?
Use Python 3. I am only half joking. Switching to unicode instead of
bytes as the default text type fixed numerous
Ben Finney wrote:
>> I don't think this is possible with the print statement, but the
>> print() function can be replaced with anything you like:
>
>
> Hmm. I am more looking for something that doesn't involve replacing
> ‘print’, but rather to hook into whatever it uses to coerce the type of
>
Laura Creighton writes:
> Hmm, now that I read the six document again
> @six.python_2_unicode_compatible
Peter Otten <__pete...@web.de> writes:
> I don't think this is possible with the print statement, but the
> print() function can be replaced with anything you like:
Hmm. I am more lookin
Ben Finney wrote:
> Ben Finney writes:
>
>> In Python 2.7, I am seeing this behaviour for ‘print’::
>>
>> Python 2.7.10 (default, Sep 13 2015, 20:30:50)
>> [GCC 5.2.1 20150911] on linux2
>> Type "help", "copyright", "credits" or "license" for more
>> information.
>> >>> from
Hmm, now that I read the six document again
@six.python_2_unicode_compatible
seems exactly what you are asking for ...
https://pythonhosted.org/six/
Laura
--
https://mail.python.org/mailman/listinfo/python-list
I think the thing you want to converse is your stringIO not your print.
I think you do this using six.stringIO
https://pythonhosted.org/six/
But I have only read the doc, not done this in practice.
Laura
--
https://mail.python.org/mailman/listinfo/python-list
Ben Finney writes:
> In Python 2.7, I am seeing this behaviour for ‘print’::
>
> Python 2.7.10 (default, Sep 13 2015, 20:30:50)
> [GCC 5.2.1 20150911] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from __future__ import unicode_literals
>