>> 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.

>>> Many decisions in programming languages are arbitrary.
>> In Java, strings have .length(), arrays have .length, and collections have 
>>.size(). You don't have to write wholly new functions. We could keep the 
>>globals and just add wrappers:
class Iterable:
def length(self): return len(self) # list or dict
def map(self, f): return map(f, self)) # list
def map(self, f): return map(f, self.iteritems()) # dict

And this circles back around to my original point. Python is the only language 
people use. Only a very small few get to have 1 language. The rest of us are 
stuck switching languages, experiencing pain and ambiguity when writing code. I 
think that's a legitimate criticism. We've got Python as an outlier with no 
property or method for length of a collection (C++/Java/JS). I don't care if 
it's implemented as all the same function, but being the exception is a 
drawback. (FWIW, I don't like size() unless it's referring to storage size 
which isn't necessarily equal to the number of iterables.)

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.

As for the English language parsing of map(f, list), it's a simple matter of 
taking what you have - an iterable, and applying the function to them. You 
start with shoes that you want to be shined, not the act of shining then apply 
that to the shoes. It's like the saying when all you have is a hammer, 
everything starts to look like a nail.  You're better off only hammering nails. 

_______________________________________________
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