Nested function scope problem
Justin Azoff
justin.azoff at gmail.com
Fri Jul 21 23:02:16 EDT 2006
Simon Forman wrote:
> That third option seems to work fine.
Well it does, but there are still many things wrong with it
if len(tok) > 0:
should be written as
if(tok):
tok = ''
tok = toc + c
should be written as
tok = []
tok.append(c)
and later
''.join(toc)
anyway, the entire thing should be replaced with something like this:
import re
def breakLine(s):
splitters = '?()&|:~,'
chars = '^ \t\n\r\f\v%s' % splitters
regex = '''(
(?:[%s])
|
(?:[%s]+))''' % (splitters, chars)
return re.findall(regex, s,re.VERBOSE)
That should be able to be simplified even more if one were to use the
character lists built into the regex standard.
--
- Justin
More information about the Python-list
mailing list