#!/usr/local/bin/python2 s = '{dfsghg}dasfgh' for i in xrange(1000000): _, t = s.rsplit('}', 1) print t