NEWbie asks "is Python a good tool for automated file/folder generation?"

Peter Hansen peter at engcorp.com
Tue Jun 18 20:44:47 EDT 2002


Chris Barker wrote:
> 
> Peter Hansen wrote:
> > Better to learn to use raw-strings, with an "r" in front,
> > as in path = r"c:\this is a safe path" or better yet,
> > either forward slashes always: path = "c:/this works too".
> 
> Or even better, use os.path.join(), you never know when you will
> encounter a Mac. (of course, if it's OSX, the above will work as well)

I started writing that, then went to the interactive prompt
and concluded (after brief experimentation) that there was
no way to join the "c:" and the "this works too" portions
of the path without explicitly specifying a "/" to force it
to be an absolute path.  Doubtless I did something wrong,
but I decided to avoid the issue by skipping any mention of
os.path.join().

Of course, since drive letters are not portable anyway this
is all a moot point.  For any hardcoded path like that, 
you can't have a very good cross-platform solution I suppose.

-Peter



More information about the Python-list mailing list