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

2006-03-21 Thread stv
Hey all, I would like to expand the "visual" representation of a tree hierarchy, given below, where child-ness is defined by indentation, and folder-ness is highlighted with a trailing '/' Input (test.txt): dir1/ file1 file2 1-1/ file3 file4

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 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.st

[Tutor] Inner Class access to outer class attributes?

2006-03-23 Thread stv
# So I figure out inner classes while typing the # first draft of this email, at least mostly # How do I access the "outer" class attributes from # the inner class? class GroupLocation(list): ### Note subclass of list class _Sublocation(object): def __init__(self, sublocation, action):

Re: [Tutor] Inner Class access to outer class attributes?

2006-03-23 Thread stv
Hmmm, so every Sublocation object has a copy of the grouplocation data? What happens if I come around & change something: group.grouplocation = differentGroupLocationID Would I need to (forgive me here if I get some terms wrong) use a property (or a setter) & then loop over all the affected sublo

Re: [Tutor] Inner Class access to outer class attributes?

2006-03-24 Thread stv
> The problem appears to be that you need to read a bit more > about Pythons handling of variable names and objects. :-) Or learn to spend a bit more time digesting the helpful advice given here ... between this & the searching between two lists thread the quality of advice has been excellent. I

Re: [Tutor] Learning Python

2006-03-28 Thread stv
If you're a bookish type, I found Magnus Lie Hetland's "Beginning Python" excellent. It's really more than a beginners books. I came to Python with a scripting background--mostly lightweight OS stuff (Applescript, DOS) as well as a lot of lightweight application programming (Filemaker, SQL, VBA for

[Tutor] List methods/comps Best Practices

2006-04-03 Thread stv
I just thumped my head against the wall for a few hours on something, and I was wondering if it's just my green-ness in Python, or if I'm doing something unsavory. I had several list comprehensions that I was mucking with; these lists are working on a simple subclass of the built-in list object. T

Re: [Tutor] List methods/comps Best Practices

2006-04-03 Thread stv
> So don't write: > [adds.add_changes('foo', path) for path in filelist] > but: > for path in filelist: adds.add_changes('foo', path) Excellent point; new toy, got carrid away :) I feel silly on that one. And now that I've made the return list.extend(foo) mistake, I'll surely neve- ... er, wa

Re: [Tutor] Books

2006-05-03 Thread stv
> "Beginning Python: From Novice to Professional", by > Magnus Lie Hetland > Publisher: Apress (September 26, 2005) > ISBN: 159059519X I would heartily second this recommendation. Different folks have different learning styles, and having a good overview can make weeding out the internet informati

Re: [Tutor] Any Good book for python

2007-01-04 Thread stv
d. I'll read Pilgrim's book in the near future. In general (with the notable exception of the Plone book) I've found the Apress materials excellent. (Both books happen to be Apress, no I'm not affiliated in any way). --stv ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor