Unnamed
public python v1 · immutabledef stripcom(s,delim="#"): c=0 state=None lits=["'",'"'] while c<len(s)-len(delim)+1: if s[c] in lits and (c>0 and s[c-1]!="\\"): if state==None: state=lits.index(s[c]) else: if s[c]==lits[state]: state=None if state==None and s[c:c+len(delim)]==delim: return s[:c] c=c+1 return s