from pyparsing import Keyword, javaStyleComment, dblQuotedString
keyword = 'public'
expr = Keyword(keyword).ignore(javaStyleComment | dblQuotedString)
Trying to find all instances of a keyword NOT in comments or literals?