On Mon, Jun 21, 2010 at 10:28 PM, Stephen J. Turnbull <step...@xemacs.org> wrote: > Michael Urman writes: > > > It is somewhat troublesome that there doesn't appear to be an obvious > > built-in idempotent-when-possible function that gives back the > > provided bytes/str, > > If you want something idempotent, it's already the case that > bytes(b'abc') => b'abc'. What might be desirable is to make > bytes('abc') work and return b'abc', but only if 'abc' is pure ASCII > (or maybe ISO 8859/1).
No, no, no! That's just what Python 2 did. > Unfortunately, str(b'abc') already does work, but > > st...@uwakimon ~ $ python3.1 > Python 3.1.2 (release31-maint, May 12 2010, 20:15:06) > [GCC 4.3.4] on linux2 > Type "help", "copyright", "credits" or "license" for more information. >>>> str(b'abc') > "b'abc'" >>>> > > Oops. You can see why that probably "should" be the case. There is a near-contract that str() of pretty much anything returns a "printable" version of that thing. -- --Guido van Rossum (python.org/~guido) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com