[Python-ideas] Make map() better

Antoine Rozo antoine.rozo at gmail.com
Thu Sep 14 17:03:23 EDT 2017


> Why? I can iterate over a string. [c for c in 'abc'] It certainly behaves
like one... I'd say this is inconsistent because there is no __iter__() and
next() on the str class.

Yes, strings are iterables. You can use a string as argument of str.join
method.
But only strings can be used as separators, so there is non need for a
generic join method for all types of separators.

Python is well designed, you are just not used to it

2017-09-14 21:31 GMT+02:00 Chris Angelico <rosuav at gmail.com>:

> On Fri, Sep 15, 2017 at 5:06 AM, Jason H <jhihn at gmx.com> wrote:
> >
> >>> Why is it ','.join(iterable), why isn't there join(',', iterable)
> >
> >> Because join apply on a string, and strings are defined by the str
> class, not by a specific protocol (unlike iterables).
> > Why? I can iterate over a string. [c for c in 'abc'] It certainly
> behaves like one... I'd say this is inconsistent because there is no
> __iter__() and next() on the str class.
>
> There is __iter__, but no next() or __next__() on the string itself.
> __iter__ makes something iterable; __next__ is on iterators, but not
> on all iterables.
>
> >>> "abc".__iter__()
> <str_iterator object at 0x7fce2b672550>
>
> > I do think Python is superior in many, many, ways to all other
> languages, but as Python and JS skills are often desired in the same
> engineer, it seems that we're making it harder on the majority of the labor
> force.
> >
>
> "We" are making it harder? Who's "we"? Python predates JavaScript by a
> few years, and the latter language was spun up in less than two weeks
> in order to create an 'edge' in the browser wars. So I don't think
> anyone really planned for anyone to write multi-language code
> involving Python and JS.
>
> ChrisA
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
Antoine Rozo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170914/0de39990/attachment.html>


More information about the Python-ideas mailing list