Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97463

Re: Python 2 ‘print’, coercing arguments to Unicode

Path csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'subject:Python': 0.05; 'none:': 0.05; '__future__': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'coercion.': 0.16; 'hypothetical': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:Unicode': 0.16; 'basically': 0.18; 'working.': 0.18; 'thanks,': 0.24; 'import': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'least': 0.27; "i'm": 0.30; 'code': 0.30; 'that,': 0.34; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:org': 0.37; 'skip:p 20': 0.38; 'skip:o 20': 0.38; 'does': 0.39; 'to:addr:python.org': 0.40; 'cast': 0.66; 'him,': 0.67; 'subjectcharset:utf-8': 0.71; 'power': 0.72; '_o__)': 0.84; 'otten': 0.84; 'received:125': 0.84; 'killed': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Python 2 ‘print’, coercing arguments to Unicode
Date Wed, 07 Oct 2015 10:23:16 +1100
References <851td81g08.fsf@benfinney.id.au> <85wpv0z368.fsf@benfinney.id.au> <201510061248.t96CmCWP011700@fido.openend.se> <85si5nzo6y.fsf@benfinney.id.au> <mv1jgc$hhl$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xAC128405
X-Public-Key-Fingerprint 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-pubkey.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)
Cancel-Lock sha1:GEryJUD+1UkUSLQJiiDGOxzefS8=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.439.1444173810.28679.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1444173810 news.xs4all.nl 23729 [2001:888:2000:d::a6]:53511
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:97463

Show key headers only | View raw


Peter Otten <__peter__@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 understand it I'm looking for the hypothetical

    from __future__ import print_coerce_args_to_unicode

and without that, I'm stuck with the hard-coded ‘str’ coercion.

Thanks, at least now I can stop flailing to try to get it working.

-- 
 \       “Fear him, which after he hath killed hath power to cast into |
  `\   hell; yea, I say unto you, Fear him.” –Jesus, as quoted in Luke |
_o__)                                                             12:5 |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Python 2 ‘print’, coercing arguments to Unicode Ben Finney <ben+python@benfinney.id.au> - 2015-10-07 10:23 +1100

csiph-web