On Jan 23, 5:37 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Wed, 23 Jan 2008 11:05:01 -0800, Paul Rubin wrote: > > ryan k <[EMAIL PROTECTED]> writes: > >> Hello. I have a string like 'LNAME > >> PASTA ZONE'. I want to create a list of those words and > >> basically replace all the whitespace between them with one space so i > >> could just do lala.split(). Thank you! > > > import re > > s = 'LNAME PASTA ZONE' > > re.split('\s+', s) > > Please tell me you're making fun of the poor newbie and didn't mean to > seriously suggest using a regex merely to split on whitespace? > > >>> import timeit > >>> timeit.Timer("s.split()", "s = 'one two three four'").repeat() > > [1.4074358940124512, 1.3505148887634277, 1.3469438552856445]>>> > timeit.Timer("re.split('\s+', s)", "import re;s = 'one two > > three four'").repeat() > [7.9205508232116699, 7.8833441734313965, 7.9301259517669678] > > -- > Steven
Much thanks to Machin for helping with the parsing job. Steven D'Aprano, you are a prick. -- http://mail.python.org/mailman/listinfo/python-list