from pyparsing import *
ParserElement.DEFAULT_WHITE_CHARS=""
def sw(tk):
return [tk[1],tk[0]]
rl1=(Word(" \t\n")+Word("\.,;:)]}")).setParseAction(sw)
rl2=(Word("([{")+Word(" \t\n")).setParseAction(sw)
print rl2.transformString(rl1.transformString("asda ; asdads ; asd; } asd\t( adasd"))