On 2019-01-29 16:14, MRAB wrote:
On 2019-01-29 23:38, Greg Ewing wrote:
Brendan Barnwell wrote:
    Personally what I find is perverse is that .join is a method of
strings but does NOT call str() on the items to be joined.

Neither do most other string methods:

  >>> s = "hovercraft"
  >>> s.count(42)
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
TypeError: Can't convert 'int' object to str implicitly

Why should join() be any different?

And what if you don't want str, but instead repr, or ascii?

Then you can still convert them yourself beforehand, and any stringifying that .join did would be a no-op. If you want to call repr on all your stuff beforehand, great, then you'll get strings and you can join them just like anything else. But you'll ADDITIONALLY be able to not pre-stringify them in a custom way, in which case they'll be stringified in the default way.

--
Brendan Barnwell
"Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail."
   --author unknown
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to