
Sept. 11, 2021
1:20 a.m.
On 9/9/21 12:04 PM, Terry Reedy wrote:
Except that .to_bytes already exists, and arguably should have had such defaults from the beginning, making any new function to do the same thing superfluous.
New functions aren't always about new functionality; sometimes they are about increased usability. Everything in the PEP can already be accomplished, just not easily: bstr = b'hello world' bchr = bstr.getbyte(7) # proposed bchr = bstr[7:8] # existing for bchr in bstr.iterbytes(): # proposed ... for num in bstr: # existing bchr = bytes([bchr]) bchr = bytes.fromint(65) # proposed bchr = bytes([65]) # existing -- ~Ethan~