[Python-ideas] str.split with empty separator (original) (raw)
Alexandre Conrad alexandre.conrad at gmail.com
Thu Jul 29 12:41:35 CEST 2010
- Previous message: [Python-ideas] Distutils setup.py & per user site packages
- Next message: [Python-ideas] str.split with empty separator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hello all,
What if str.split could take an empty separator?
'banana'.split('') ['b', 'a', 'n', 'a', 'n', 'a']
I know this can be done with:
list('banana') ['b', 'a', 'n', 'a', 'n', 'a']
I think that, semantically speaking, it would make sens to split where there are no characters (in between them). Right now you can join from an empty string:
''.join(['b', 'a', 'n', 'a', 'n', 'a'])
So why can't we split from an empty string?
This wouldn't introduce any backwards incompatible changes as str.split currently can't have an empty separator:
'banana'.split('') Traceback (most recent call last): File "", line 1, in ValueError: empty separator
I would love to see my banana actually split. :)
Regards,
Alex twitter.com/alexconrad
- Previous message: [Python-ideas] Distutils setup.py & per user site packages
- Next message: [Python-ideas] str.split with empty separator
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]