[Python-Dev] PEP 461 - Adding % and {} formatting to bytes (original) (raw)
Isaac Morland ijmorlan at uwaterloo.ca
Wed Jan 15 17🔞54 CET 2014
- Previous message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Next message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 15 Jan 2014, Antoine Pitrou wrote:
On Wed, 15 Jan 2014 15:47:43 +0000 (UTC) Neil Schemenauer <nas at arctrix.com> wrote:
Objects that implement str can also implement bytes if they can guarantee that ASCII characters are always returned, no matter what the value I think that's a slippery slope. bytes should mean that the object has a well-known bytes equivalent or encoding, not that its str happens to be pure ASCII.
+1
(for example, it would be fine for a HTTP message class to define a bytes method)
Also, consider that if e.g. float had a bytes method, then bytes(2.0) would start returning b'2.0', while bytes(2) would still need to return b'\x00\x00'.
Not actually suggesting the following for a number of reasons including but not limited to the consistency of floating point formats across different implementations, but it would make more sense for bytes (2.0) to return the 8-byte IEEE representation than for it to return the ASCII encoding of the decimal representation of the number.
Isaac Morland CSCF Web Guru DC 2619, x36650 WWW Software Specialist
- Previous message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Next message: [Python-Dev] PEP 461 - Adding % and {} formatting to bytes
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]