[Pythonmac-SIG] about this x-platform stuff...

Richard Gordon richard@richardgordon.net
Sat, 14 Apr 2001 16:41:38 -0400


hi Corran & thanks for the reply.

>The os and os.path modules are what you want, I suspect.  For example
>
>infile = os.path.join('thisdir', 'thatdir', 'otherdir', 'myfile')
>
>will do the equivalent of what you describe, inserting the correct 
>separator in the appropriate places on different platforms.

ok, that's only a little clunky and certainly better than trying to 
use an inline variable to form the path string. I'll keep this in 
mind.

>The variable os.sep holds the standard separator for the platform if 
>you need to get at it directly, but be careful that obvious things 
>like:
>
>['thisdir', 'thatdir', 'otherdir', 'myfile'].join(os.sep)
>
>are not cross-platform.  This is a relative path on unix and an 
>absolute path on the mac, for example.

sigh.

>You may find some routines in the url and urlparse module useful as well.

I'll have a look. Thanks again.


Richard Gordon
--------------------
Gordon Design
Web Design/Database Development
http://www.richardgordon.net