[Pythonmac-SIG] cross platform os.path.nornpath problem
Martina Oefelein
Martina@Oefelein.de
Thu, 19 Sep 2002 21:21:59 +0200
Hi Stephen:
> import os
> print os.path.normpath( "foo/goo/file.txt" )# a unix relative path
> (result) >>> :foo/goo/file.txt
>
> Well, of course! "/" are valid chars in a Mac file name, so the
> operation
> worked as intended. I would have liked to have the result be
> "file.txt". Is
> there a way within Python 2.2.1 that I could do this with writing our
> own
> special normalizer?
I'm using urllib for this purpose:
from urllib import url2pathname, pathname2url
print os.path.normpath(url2pathname("foo/goo/file.txt"))
should do the job
ciao
Martina