[Python-ideas] Make map() better

David Mertz mertz at gnosis.cx
Fri Sep 15 10:42:57 EDT 2017


On Sep 15, 2017 7:23 AM, "Jason H" <jhihn at gmx.com> wrote:

Another pain point is python uses [].append() and JS uses [].join() Having
a wrapper for append would be helpful.


There should be one, and only one, obvious way to do it.

And for that matter, why isn't append/extend a global? I can add things to
lots of different collections. lists, sets, strings...


This is a key misunderstanding. You CANNOT "append" to lots of collections.

You can ADD to a set, which has a quite different semantics than appending
(and hence a different name). You can neither add nor append to a string
because they are immutable.

I can imagine various collections where appending might make sense (mutable
strings?). None of them are in builtins. If a 3rd party wrote such a
collection with append semantics, they'd probably name it append... e.g.
collections.deque has an "append" (but also an "appendleft").
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170915/1ebf1a87/attachment.html>


More information about the Python-ideas mailing list