[Python-ideas] Deprecating rarely used str methods

Chris Angelico rosuav at gmail.com
Mon Aug 12 00:58:07 CEST 2013


On Sun, Aug 11, 2013 at 11:50 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> To add to that, the special treatment of tuples and sometimes dicts lead to
> bugs or unexpected exceptions.
>>>> '%s' % [1,]
> '[1]'
>>>> '%s' % (1,)
> '1'
>>>> '%s' % [1,2,3]
> '[1, 2, 3]'
>>>> '%s' % (1,2,3)
> Traceback (most recent call last):
>   File "<pyshell#1>", line 1, in <module>
>     '%s' % (1,2,3)
> TypeError: not all arguments converted during string formatting

This is why I would prefer printf to be a function, rather than an
operator. The operator is a coolness that has a cost.

ChrisA


More information about the Python-ideas mailing list