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).
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.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com