On May 4, 4:54 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar> wrote: > En Mon, 04 May 2009 15:12:41 -0300, mzdude <jsa...@cox.net> escribió: > > > substring isn't limited to 0..255 > >>>> substring = "\0x%d\0x%d" % (257,257) > >>>> 'acaccgac'.replace("ac", substring) > > '\x00x257\x00x257\x00x257\x00x257cg\x00x257\x00x257' > > This isn't what you think it is. Look carefully: > > py> substring = "\0x%d\0x%d" % (257,257) > py> len(substring) > 10 > py> list(substring) > ['\x00', 'x', '2', '5', '7', '\x00', 'x', '2', '5', '7'] > > -- > Gabriel Genellina
OOPS. My bad. But I'm not going to give up. l = ['a','b','c','a','c'] us = unicode("".join(l)) substr = unichr(257) + unichr(257) us = us.replace(u'ac',substr) print len(us) print list(us) output is >>> 5 [u'a', u'b', u'c', u'\u0101', u'\u0101'] -- http://mail.python.org/mailman/listinfo/python-list