[Python-ideas] Deprecating repr() and the like

Tim Peters tim.peters at gmail.com
Fri Aug 9 22:52:00 CEST 2013


[Serhiy Storchaka]
>> repr(), ascii() and one-argument str() can be deprecated and removed in
>> Python 5.0 because they are redundant and can be expressed as a simple
>> formatting:
>>
>> repr(x) == '%r'%(x,) == '{!r}'.format(x)
>> ascii(x) == '%a'%(x,) == '{!a}'.format(x)
>> str(x) == '%s'%(x,) == '{}'.format(x)
>>
>> We also can deprecate string concatenation for the same reason:
>>
>> s1 + s2 == '%s%s'%(s1,s1) == '{}{}'.format(s1,s2) == ''.join([s1,s2])

And don't forget the digit 1!  It looks too much like lowercase letter
L.  It would be silly require constructs like 42 // 42 instead, so
let's add a new builtin "one":

>>> 1
SyntaxError: invalid syntax
>>> one == 42 // 42
True
>>> one
1

I'm not sure how to replace the confusing output from that last line ;-)


More information about the Python-ideas mailing list