<snip everything> > That is clearer. At this point, though, you don't need the enumerator any > more > (so you can avoid indexing each item):
Good point. > > def xgen(s): > srciter = iter(s) > item = [srciter.next()] > for i in srciter: > if i == '/': > item.append(srciter.next()) > else: > yield item > item = [i] > yield item > For some reason, keeping the != first feels a lot more logical to me, but I think that's just a reflection of my particular mental model of the problem. Also, item is a much clearer name than stack; I chose stack just to point out how similar the solution to objection 2 was to yours. Peace Bill Mill bill.mill at gmail.com -- http://mail.python.org/mailman/listinfo/python-list