[Python-ideas] textFromMap(seq , map=None , sep='' , ldelim='', rdelim='')
bborcic at gmail.com
Wed Oct 27 14:17:44 CEST 2010
Carl M. Johnson wrote:
> The downside of flipping the object and parameter of split is that
> there's no clear thing to translate "blah\tblah\nblah".split() ==>
> ['blah', 'blah', 'blah'] into. None.split(string) is crazy talk.
''.join(seqofstr) is deemed better-looking than sum(seqofstr), isn't it? Imo,
this entails an aesthetic canon in favor of ''.split in the above context. Note
that currently s.split('') bombs, so there would be no functional behavior to save.
> again, the case can be made that split() doesn't behave like the other
> splits (it drops empty segments; it treats all whitespace the same),
> so maybe it shouldn't have the same name as the normal kind of split.
> I do think that it might be convenient to be able to do this:
> commasplit = ', '.divide #If we're going to imagine this, we should
> probably use a different name than "split"
> list1 = commasplit(string1)
> list2 = commasplit(string2)
> The same way that one can do:
> commajoin = ', '.join
> string1 = commajoin(list1)
> string2 = commajoin(list2)
Yeah, that's a concrete rendition of my earlier point on bound methods.
> But the convention is too old and the advantage is too slight to
> bother with sort of bikeshedding now. Save it for when you design a
> new language to replace Python. :-)
Thanks :) But if I was to redesign the snake, I guess I might contemplate
pieces = string/separator
pieces = string.split(separator)
More information about the Python-ideas