def removeblanklines(astr): """ removeblanklines(astr) returns the string after remove blank lines in 'astr' """ linesep = mylib3.getlinesep(astr) alist = astr.split(linesep) lss = [] for element in alist: ell = element.strip() if ell != '': lss.append(element) st1 = linesep.join(lss) return st1
def removecomment(astr, cphrase): """ the comment is similar to that in python. any charachter after the # is treated as a comment until the end of the line astr is the string to be de-commented cphrase is the comment phrase""" linesep = mylib3.getlinesep(astr) alist = astr.split(linesep) for i in range(len(alist)): alist1 = alist[i].split(cphrase) alist[i] = alist1[0] # return string.join(alist, linesep) return linesep.join(alist)