(original) (raw)

On 1/15/2014 4:03 PM, Steven D'Aprano wrote:
What precisely does it do? If it's so obvious, why is this thread so   
long?

It produces a formatted representation of the object in bytes. For numbers, that would probably be expected to be ASCII digits and punctuation.

But other items are not as obvious.

bytes would probably be expected not to have a \_\_bytes\_format\_\_, but if a subclass defined one, it might be HEX or Base64 of the base bytes. Or if the subclass is ASCII text oriented, it might be the ASCII text version of the base bytes (which would be identical to the base bytes, except for the type transformation).

str would probably be expected not to have a \_\_bytes\_format\_\_, but if a subclass defined one, it might be HEX or Base64, or it might be a specific encoding of the base str.

Other objects might generate an ASCII \_\_repr\_\_, if they define the method.


It took a lot of talk to reach the conclusion, if it has been reached, that none of the solution are general enough without defining something like \_\_bytes\_format\_\_. And before that, a lot of talk to decide that % interpolation already had an ASCII bias.