[Python-Dev] PEP 460: allowing %d and %f and mojibake (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Tue Jan 14 23:07:15 CET 2014
- Previous message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Next message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 15 Jan 2014 08:00, "Greg Ewing" <greg.ewing at canterbury.ac.nz> wrote:
Guido van Rossum wrote:
def spam(a): r = asciistr('(') if a: r += a.strip() r += asciistr(')') return r The general fix would be to add else: r += a[:0] The awkwardness might be reducable if asciistr let you write something like r = asciistr('(', a) meaning "give me either a string or bytes containing the value '(', depending on the type of a". But taking a step back, how bad would it really be if an asciistr were returned in this case? Is it just that asciistr doesn't behave exactly like a str in all situations, so it might break something? If so, would it help if asciistr were a built-in type, so that other things could be made aware of it?
That way lies the Python 2 text model, and we're not going there. It's probably best to think of asciistr as a way of demonstrating a rhetorical point about the superiority of the Python 3 text model rather than something that anyone should actually use in production Python 3 code (although, depending on how rough the edges turn out to be, it might eventually find a place in some single source 2/3 code bases, as well as in prototype code and personal scripts).
Cheers, Nick.
-- Greg
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140115/52c7dcf7/attachment-0001.html>
- Previous message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Next message: [Python-Dev] PEP 460: allowing %d and %f and mojibake
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]