[Python-ideas] Optional keepsep argument in str.split()
Marco Buttu
mbuttu at oa-cagliari.inaf.it
Wed Aug 28 23:14:12 CEST 2013
On 08/28/2013 09:36 PM, Masklinn wrote:
> and the "keeping" split can be handled via findall:
>
>>>> >>>re.findall(r'([^n]+(?:n|$))', "python3")
> ['python', '3']
Of course, but this is not built-in and not obvious. Furthermore, a
regex is not so trivial as the built-in solution, as
you can see:
>>> re.findall(r'([^n]+(?:n|$))', "pythonn3")
['python', '3']
>>> 'pythonn3'.split(sep='n', keepsep=True)
['python', 'n', '3']
Regards,
--
Marco Buttu
INAF Osservatorio Astronomico di Cagliari
Loc. Poggio dei Pini, Strada 54 - 09012 Capoterra (CA) - Italy
Phone: +39 070 71180255
Email: mbuttu at oa-cagliari.inaf.it
More information about the Python-ideas
mailing list