[Python-ideas] The non-obvious nature of str.join (was Re: sum(...) limitation)
Ethan Furman
ethan at stoneleaf.us
Mon Aug 11 23:10:31 CEST 2014
On 08/11/2014 10:53 AM, Nathaniel Smith wrote:
>
> But practically speaking, how would this work? In general str.join and
> sum have different semantics. What happens if we descend deep into the
> iterable and then discover a non-string (that might nonetheless still
> have a + operator)?
The same thing that happens now if you pass a list to join with a non-string entry:
--> ' '.join(['some', 'list', 'of', 'words', 'and', 10, 'as', 'a', 'number'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence item 5: expected string, int found
--
~Ethan~
More information about the Python-ideas
mailing list