Neil Cerutti wrote:
On 2010-06-17, Ian Kelly <ian.g.ke...@gmail.com> wrote:
On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti
<ne...@norwich.edu> wrote:
What's the best way to do the inverse operation of the .join
function?
Use the str.split method?

split is perfect except for what happens with an empty string.

I see what you mean.

This is consistent:

>>> ','.join([''])
''
>>> ''.split(',')
['']

but this isn't:

>>> ','.join([])
''
>>> ''.split(',')
['']

An empty string could be the result of .join(['']) or .join([]).

Should .split grow an addition keyword argument to specify the desired
behaviour? (Although it's simple enough to define your own function.)
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to