[Python-3000] Does bytes() need to support bytes(, )? (original) (raw)
Gregory P. Smith greg at krypto.org
Tue Aug 28 01:33:45 CEST 2007
- Previous message: [Python-3000] Does bytes() need to support bytes(, )?
- Next message: [Python-3000] Does bytes() need to support bytes(, )?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
+1 from me, i don't see a reason for bytes(s, e) to exist when s.encode(e) does the same job and is more symmetric.
On 8/27/07, Guido van Rossum <guido at python.org> wrote:
I'm still working on stricter enforcement of the "don't mix str and bytes" rule. I'm finding a lot of trivial problems, which are relatively easy to fix but time-consuming.
While doing this, I realize there are two idioms for converting a str to bytes: s.encode(e) or bytes(s, e). These have identical results. I think we can't really drop s.encode(), for symmetry with b.decode(). So is bytes(s, e) redundant? To make things murkier, str(b, e) is not quite redundant compared to b.encode(e), since str(b, e) also accepts buffer objects. But this doesn't apply to bytes(s, e) -- that one only accepts str. (NB: bytes(x) is a different API and accepts a different set of types.) -- --Guido van Rossum (home page: http://www.python.org/~guido/)
Python-3000 mailing list Python-3000 at python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/greg%40krypto.org
- Previous message: [Python-3000] Does bytes() need to support bytes(, )?
- Next message: [Python-3000] Does bytes() need to support bytes(, )?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]