[Python-Dev] PEP 461 - Adding % and {} formatting to bytes (original) (raw)

Yury Selivanov yselivanov.ml at gmail.com
Tue Jan 14 22:44:16 CET 2014


On January 14, 2014 at 4:36:00 PM, Ethan Furman (ethan at stoneleaf.us) wrote:

On 01/14/2014 12:57 PM, Antoine Pitrou wrote: > On Tue, 14 Jan 2014 11:56:25 -0800 > Ethan Furman wrote: >> >> %s, because it is the most general, has the most convoluted resolution: >> >> - input type is bytes? >> pass it straight through > > It should try to get a Pybuffer instead. Meaning any bytes or bytes-subtype will support the Pybuffer protocol, and this should be the first thing we try? Sounds good. For that matter, should the first test be "does this object support Pybuffer" and not worry about it being isinstance(obj, bytes)?

>> - input type is numeric? >> use its xxx [1] [2] method and ascii-encode it (strictly) > > What is the definition of "numeric"? That is a key question.

isinstance(o, numbers.Number) ?

Yury



More information about the Python-Dev mailing list