[Pythonmac-SIG] alias question

Just van Rossum just@letterror.com
Fri, 26 Feb 1999 22:20:14 +0100


At 12:45 PM -0800 2/26/99, Joseph J. Strout wrote:
>-- but I do the same thing with a FileCrawler class, which lets you define
>behavior to take for docs, folders, doc aliases, and folder aliases:

Cool class, Joe!

Two nitpicks:

>import mac
[ ... ]
>	def crawl(self, path):
>		files = mac.listdir(path)

Never import "mac" directly, all its functionality is available from os. I
guess the docs aren't too clear about this. "mac" is the equivalent of the
posix module on unix, which you also shouldn't use directly.

>			if path[-1] == ':': fpath = path + fname
>			else: fpath = path + ':' + fname

Ah, here's another neat function from os.path which you could use instead:

			fpath = os.path.join(path, fname)

(it's cross platform, too!)

Just