Re: [Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread stv
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

Re: [Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread stv
> 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

Re: [Tutor] Pythonic? Building a full path from a "visual" file tree

2006-03-21 Thread Kent Johnson
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