3 ms·
How come `bytes` and `bytearray` got old-style formatting? Aren't we trying to do away with that in favor of a `format` method?
by davesque 11y ago
How come `bytes` and `bytearray` got old-style formatting? Aren't we trying to do away with that in favor of a `format` method?
- theVirginian 11y agoI think the general opinion is "use where appropriate but be consistent" which I tend to agree with. There are times where the simplicity of old-style formatting just gets the job done but it certainly has it's limitations and new style can be extremely powerful.
- ngoldbaum 11y agoIt's much more convenient to decode bytestreams (e.g. for a wire protocol) using % formatting. The lack of % formatting for bytes was a huge impediment for porting mercurial to python3, just as an example.
- davesque 11y agoCould you point me to a code example? It's hard to see how old-style formatting would facilitate decoding. Typically, I think of decoding as being a process which deconstructs something; not like formatting, which is really more about constructing.
- takeda 11y agoI think he just meant encoding, which is true. I remember Armin Ronacher (author of many nice things, especially Flask) even wrote a blog post against Python 3 and this was one of things he hated about it.