On 3/21/06, stv <[EMAIL PROTECTED]> wrote: > > import string > > def expand_tree(filetree): > indent = '\t' > stack = [] > for f in filetree: > indents = f.count(indent) > while len(stack) > indents: stack.pop() > stack.append(f.strip()) > yield string.join(stack,'') > if not f.endswith('/'): stack.pop()
> The real-world solution will use a regex to find run > of spaces at the start of element 'f'. Hmmm, I'm having to rethink this ... regex will probably not do what I want (count instance of "indent" ... or, even if regex will do, there's probably a cleaner solution without it. Given the subversion problem space (where I can count on 1 space for each level of child-ness), are there cleaner solutions than this: indents = len(f) - len(f.lstrip()) _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor