Mike Orr wrote: > I think you meant to say Perl in that sentence. In Python there > should be one way to do it, and beautiful is better than ugly. The > os.path functions are bad enough, but shutil.copy2 is just plain evil.
I agree a decent pathlib may make many of the low-level filesystem manipulation modules obsolete - just not necessarily all of them. Until we get an actual module to experiment with, we won't really know. > Is it that much of a step to translate: > > Y="$(dirname $(dirname $X))/lib" > > as > > y = Path(x).parent.parent + "lib" > y = Path(x).parent.parent.join("lib") > or whatever the syntax do jour is I'd suggest something like: y = Path(x).parent(2) + "lib/" Where the parent function works like (based on the three-part internal data approach I posted recently): def parent(self, generation=1): return type(self).from_parts( self.basepath, self.dirparts[:-generation], ()) And path addition is equivalent to: def __add__(self, other): if isinstance(other, basestring): other = Path(other) if self.nameparts: raise ValueError("Cannot add to path with non-empty name") if other.basepath: raise ValueError("Cannot append non-relative path") dirparts = self.dirparts + other.dirparts return type(self).from_parts( self.basepath, dirparts, other.nameparts) Anyway, I'll try to find some time to look at this on the Wiki. It'll be easier to bat code back and forth over there. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com