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
> The list comp is fine but I don't think you need it
> at all, since you strip() the string before you
> add it to stack.
Ahh yes. I used the rstrip() in development, printing intermediary
output to stdout, so I could see what my input file-to-list looked
like (and it looked ugly with all those E
stv wrote:
> I considered several brute-force solutions, but I persevered and came
> to, what I think, is a more Pythonic solution. What do you think?
Looks pretty sweet to me :-)
>
> import string
>
> def expand_tree(filetree):
> indent = '\t'
> stack = []
> for f in filetree:
> inden