[Python-ideas] Optional keepsep argument in str.split()
Ryan Gonzalez
rymg19 at gmail.com
Wed Aug 28 21:44:03 CEST 2013
Sounds interesting...not sure about how often it'd be used, since I could
always use re:
re.split('(n)', 'python3')
On Wed, Aug 28, 2013 at 1:42 PM, Marco Buttu <mbuttu at oa-cagliari.inaf.it>wrote:
> What do you think about an optional `keepsep` argument in str.split(), in
> order to keep the separator?
> Something like the `keepends` of str.splitlines():
>
> >>> 'I am\ngoing\nto...'.splitlines(**keepends=True)
> ['I am\n', 'going\n', 'to...']
>
> For instance:
>
> >>> 'python3'.split('n')
> ['pytho', '3']
> >>> 'python3'.split('n', keepsep=True)
> ['python', '3']
>
> Regards, Marco
>
> --
> 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
>
> ______________________________**_________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/**mailman/listinfo/python-ideas<http://mail.python.org/mailman/listinfo/python-ideas>
>
--
Ryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20130828/bcbe7f92/attachment.html>
More information about the Python-ideas
mailing list