<br><br>On Thu, Dec 17, 2009 at 19:49, Hugo Arts <<a href="mailto:hugo.yoshi@gmail.com">hugo.yoshi@gmail.com</a>> wrote:<br><br>> Probably easiest to use a regular expression to fix that particular<br>> thing, as in:<br>
><br>> import re<br>> mult_space = re.compile(r'\s+')<br>> def prestrings2list(a_str):<br>> return [re.sub(mult_space, ' ', x).strip() for x in a_str.split(',')]<br>><br>> Hugo<br>
<br>That's perfect, Hugo! <br><br>========================================<br><span style="font-family: courier new,monospace;">a_str = "blender , synthetic DNA, myrmecology, fungi, quorum sensing, theoretical physic's, reason, love, hope, virtual reality, google operating system, space, life, mystery, truth's, universe, immortality, strangeness, fun ,living, hope, eternity, knowledge, Egyptian secrets of the dead, n-space, hyper-time , theory of everything, light, nuclear theory, particle theory, myrmec, self replicating RNA, MMOG, MMOR%PG, symbiosis,Black's Plague, selddir, Da Vinci, Newton, Archimedes, Cantor7, Leibnitz, myrmecology"</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">def prestrings2list(a_str):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> import re</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> mult_space = re.compile(r'\s+')</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> return [re.sub(mult_space, ' ', x).strip() for x in a_str.split(',')]</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">lst = prestrings2list(a_str)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">print(lst) </span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">=================================================</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">OUTPUT</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">['blender', 'synthetic DNA', 'myrmecology', 'fungi', 'quorum sensing', "theoretical physic's", 'reason', 'love', 'hope', 'virtual reality', 'google operating system', 'space', 'life', 'mystery', "truth's", 'universe', 'immortality', 'strangeness', 'fun', 'living', 'hope', 'eternity', 'knowledge', 'Egyptian secrets of the dead', 'n-space', 'hyper-time', 'theory of everything', 'light', 'nuclear theory', 'particle theory', 'myrmec', 'self replicating RNA', 'MMOG', 'MMOR%PG', 'symbiosis', "Black's Plague", 'selddir', 'Da Vinci', 'Newton', 'Archimedes', 'Cantor7', 'Leibnitz', 'myrmecology']</span><br>
<br>Now for a better function name, and a proper docstring. Anyone?<br><br>Dick<br><br><br style="font-family: courier new,monospace;"><br>