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 firstname.lastname@example.org:
On Fri, Sep 15, 2017 at 5:06 AM, Jason H email@example.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.
<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.
ChrisA _______________________________________________ Python-ideas mailing list Pythonfirstname.lastname@example.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/