[Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
Ethan Furman
ethan at stoneleaf.us
Mon Sep 15 17:16:58 CEST 2014
More information about the Python-ideas mailing list
Mon Sep 15 17:16:58 CEST 2014
- Previous message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Next message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 09/15/2014 07:44 AM, Steven D'Aprano wrote: > On Mon, Sep 15, 2014 at 07:24:17AM -0700, Ethan Furman wrote: > >>> In Python 2, hex() calls the dunder method __hex__. That has been >>> removed in Python 3. Does anyone know why? >> >> __hex__ and __oct__ were removed in favor of __index__. __index__ returns >> the number as an integer (if possible to do so without conversion from, >> say, float or complex or ...). __hex__ and __oct__ did the same, and were >> redundant. > > No, __hex__ returned a string. It could be used to implement (say) a > floating point hex representation, or hex() of bytes. Right, sorry. I had the wrong return type in mind. Now you have to use the hex format codes. > I don't suppose anyone would support bringing back __hex__? I don't think we need another formatting operator. we already have % and .format() -- do we still have string templates? -- ~Ethan~
- Previous message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Next message: [Python-ideas] Stop displaying elements of bytes objects as printable ASCII characters in CPython 3
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list