Menu
Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
PEP: Generalised String Coercion
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="wolf" data-source="post: 1834199"><p>hi,</p><p></p><p>i guess that anyone reading this pep will agree that</p><p>*something* must be done to the state of unicode affairs</p><p>in python. there are zillions of modules out there that</p><p>have str() scattered all over the place, and they all</p><p>*break* on the first mention of düsseldorf...</p><p></p><p>i'm not quite sure myself how to evolve python to make</p><p>it grow from unicode-enabled to unicode-perfect, so for</p><p>me some discussion would be a good thing. only two</p><p>micro-remarks to the pep as it stands:</p><p></p><p>1) i dislike the naming of the function ``text()`` --</p><p>i´ve been using the word 'text' for a long time to mean</p><p>'some appropriate representation of character data',</p><p>i.e. mostly something that would pass ::</p><p></p><p> assert isinstance(x,basestring)</p><p></p><p>i feel this is a fairly common way of defining the term,</p><p>so to me a function `` text(x)`` should really</p><p></p><p>* return its argument unaltered if it passes</p><p> ``isinstance(x,basestring)``,</p><p></p><p>* try to return spefically a unicode object (by using</p><p> the ``x.__unicode__()`` method, where available)</p><p></p><p>* or return an 8bit-string (from ``x.__repr__()`` or</p><p> ``x.__str__()``)</p><p></p><p>as discussed later on in the pep, it is conceivable to</p><p>assign the functionality of the ``text()`` function of</p><p>the pep to ``basestring`` -- that would make perfect</p><p>sense to me (not sure whether that stands scrutiny in</p><p>the big picture, tho).</p><p></p><p></p><p>2) really minor: somewhere near the beginning it says ::</p><p></p><p> def text(obj): return '%s' % obj</p><p></p><p>and the claim is that this "behaves as desired" except</p><p>for unicode-issues, which is incorrect. the second line</p><p>must read ::</p><p></p><p> return '%s' % ( obj, )</p><p></p><p>or else it will fail if ``obj`` is a tuple that is not</p><p>of length one.</p><p></p><p></p><p>cheers,</p><p></p><p></p><p></p><p>_wolf</p></blockquote><p></p>
[QUOTE="wolf, post: 1834199"] hi, i guess that anyone reading this pep will agree that *something* must be done to the state of unicode affairs in python. there are zillions of modules out there that have str() scattered all over the place, and they all *break* on the first mention of düsseldorf... i'm not quite sure myself how to evolve python to make it grow from unicode-enabled to unicode-perfect, so for me some discussion would be a good thing. only two micro-remarks to the pep as it stands: 1) i dislike the naming of the function ``text()`` -- i´ve been using the word 'text' for a long time to mean 'some appropriate representation of character data', i.e. mostly something that would pass :: assert isinstance(x,basestring) i feel this is a fairly common way of defining the term, so to me a function `` text(x)`` should really * return its argument unaltered if it passes ``isinstance(x,basestring)``, * try to return spefically a unicode object (by using the ``x.__unicode__()`` method, where available) * or return an 8bit-string (from ``x.__repr__()`` or ``x.__str__()``) as discussed later on in the pep, it is conceivable to assign the functionality of the ``text()`` function of the pep to ``basestring`` -- that would make perfect sense to me (not sure whether that stands scrutiny in the big picture, tho). 2) really minor: somewhere near the beginning it says :: def text(obj): return '%s' % obj and the claim is that this "behaves as desired" except for unicode-issues, which is incorrect. the second line must read :: return '%s' % ( obj, ) or else it will fail if ``obj`` is a tuple that is not of length one. cheers, _wolf [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
PEP: Generalised String Coercion
Top