On 1/10/2014 6:02 PM, Antoine Pitrou wrote:
> On Fri, 10 Jan 2014 14:58:15 -0800
> Ethan Furman <et...@stoneleaf.us> wrote:
>> On 01/10/2014 02:42 PM, Antoine Pitrou wrote:
>>> On Fri, 10 Jan 2014 17:33:57 -0500
>>> "Eric V. Smith" <e...@trueblade.com> wrote:
>>>> On 1/10/2014 5:29 PM, Antoine Pitrou wrote:
>>>>> On Fri, 10 Jan 2014 12:56:19 -0500
>>>>> "Eric V. Smith" <e...@trueblade.com> wrote:
>>>>>>
>>>>>> I agree. I don't see any reason to exclude int and float. See Guido's
>>>>>> messages http://bugs.python.org/issue3982#msg180423 and
>>>>>> http://bugs.python.org/issue3982#msg180430 for some justification and
>>>>>> discussion.
>>>>>
>>>>> If you are representing int and float, you're really formatting a text
>>>>> message, not bytes. Basically if you allow the formatting of int and
>>>>> float instances, there's no reason not to allow the formatting of
>>>>> arbitrary objects through __str__. It doesn't make sense to
>>>>> special-case those two types and nothing else.
>>>>
>>>> It might not for .format(), but I'm not convinced. But for %-formatting,
>>>> str is already special-cased for these types.
>>>
>>> That's not what I'm saying. str.__mod__ is able to represent all kinds
>>> of types through %s and calling __str__. It doesn't make sense for
>>> bytes.__mod__ to only support int and float. Why only them?

Ah, I see. This is about the types that %s supports, not about support
for %d and %f.

>> Because embedding the ASCII equivalent of ints and floats in byte streams
>> is a common operation?
> 
> Again, if you're representing "ASCII", you're representing text and
> should use a str object.

Yes, but is there existing 2.x code that uses %s for int and float
(perhaps unwittingly), and do we want to "help" that code out? Or do we
want to make porters first change to using %d or %f instead of %s? I'll
grant you that we might be doing more harm than help by special-casing
these types. I'm just asking.

I think what you're getting at is that in addition to not calling
__format__, we don't want to call __str__, either, for the same reason.
Correct me if I'm off base, please. I'm not trying to put words in
anyone's mouth.

In any event, I think supporting %d and %f (and %i, %u, %x, %g, etc.)
inside format strings would be useful.

Eric.

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to