String handling bug in Python
Delaney, Timothy
tdelaney at avaya.com
Mon Apr 29 20:40:37 EDT 2002
> From: David Bolen [mailto:db3l at fitlinxx.com]
>
> Tim Peters <tim.one at comcast.net> writes:
>
> > Forward slashes are easier for almost everyone to type than backward
> > slashes, and work fine on Windows. Paths using forward
> slashes also run
> > 13-17 times faster in Python code, due to Python's Unix
> heritage <wink>.
>
> Just as an FYI, forward slashes don't actually work *everywhere* on
> Windows - there are notable UNC names that must use \\ as a prefix and
> won't accept // in the API. It's not that common but I've been bitten
> by it in the past.
>
> But they definitely work in any local file API.
import os.path
path = '//computer/path/to/file'
path = os.path.normpath(path)
print path
Tim Delaney
More information about the Python-list
mailing list