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