[Python-ideas] The non-obvious nature of str.join (was Re: sum(...) limitation)

Boris Borcic bborcic at gmail.com
Mon Aug 11 16:46:37 CEST 2014


Wolfgang Maier wrote:

>
> s == sep.join(s.split(sep))
>
> to anyone, they will not be confused again, but find it perfectly logical.


You are kidding, right? What will prevent them from using logic to recall the invariant mistakenly as
s == sep.join(sep.split(s)) ? If only because there are natural use cases for passing mysep.join around as a 
callable that will join with a fixed separator, and there would similarly exist use cases for mysep.split, 
while there are really none for passing around mystring.split to split a fixed string by varying separators.

This whole corner of python is a most ugly system of inconsistent acne scars in the 2.x series (dunno about 
3.x). What with sum(...) pedantically telling you to use str.join - if it knows what you want, it should just 
to it.

---
Ce courrier électronique ne contient aucun virus ou logiciel malveillant parce que la protection avast! Antivirus est active.
http://www.avast.com




More information about the Python-ideas mailing list