[Python-ideas] Deprecating repr() and the like
Ron Adam
ron3200 at gmail.com
Sat Aug 10 03:51:49 CEST 2013
On 08/09/2013 03:52 PM, Tim Peters wrote:
> [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;-)
Surely it should round trip ...
eval(str(one)) == one
and
int("one") == one
;-)
These recent threads, with many little things to improve, replace, include,
or depreciate, causes me to think we've reached a point where we need some
input and guidance on what direction to go in.
Cheers,
Ron
More information about the Python-ideas
mailing list