[Python-ideas] The non-obvious nature of str.join (was Re: sum(...) limitation)
Masklinn
masklinn at masklinn.net
Mon Aug 11 21:29:01 CEST 2014
On 2014-08-11, at 19:51 , Haoyi Li <haoyi.sg at gmail.com> wrote:
> One reason I think this is confusing is that "list.join(sep)" is how basically everyone else does it, including: Ruby, Javascript, Scala, Guava-Java (normal java doesn't have anything). People who don't do it this way include C# (static method), Boost-C++ (static method), PHP (static method)
>
> Nobody does it the Python way AFAICT.
One could easily enough argue that MLs and Haskell do: although they
don't generally have objects (and thus no method), their signature is
(function name may vary)
join :: String -> [String] -> String
join separator list
which — in haskell — can be infixed to
separator `intercalate` list
and which in both languages nicely lends itself to partial application
(much like Python's `sep.join` expression)
More information about the Python-ideas
mailing list