All pastes #24835 Raw Edit

Unnamed

public python v1 · immutable
#24835 ·published 2005-10-07 11:43 UTC
rendered paste body
def 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