Google code is icky :-) I'd write it as so, optionally using .append() and ''.join()... and .find('"')
def rqs(sexp, preserve_backslashes=False): retval = '' i=0 while sexp[i] != '"': i += 1 i += 1 while sexp[i] != '"': c = sexp[i] if c != '\\' or preserve_backslashes: retval +=c i += 1
return (i, retval) their version doesn't seem to work right when the input ends in \", unless it isn't supposed to :-)
minimally, the retval += sexp[i] else: retval += sexp[i]
is redundant...
(select post+right click+view selection source will fix indentation :-)
Comment
Google code is icky :-)
I'd write it as so, optionally using .append() and ''.join()... and .find('"')
def rqs(sexp, preserve_backslashes=False):
retval = ''
i=0
while sexp[i] != '"':
i += 1
i += 1
while sexp[i] != '"':
c = sexp[i]
if c != '\\' or preserve_backslashes:
retval +=c
i += 1
return (i, retval)
their version doesn't seem to work right when the input ends in \", unless it isn't supposed to :-)
minimally, the
retval += sexp[i]
else:
retval += sexp[i]
is redundant...
(select post+right click+view selection source will fix indentation :-)