python path separator

Nobody nobody at nowhere.com
Thu Sep 2 17:57:08 CEST 2010


On Wed, 01 Sep 2010 23:57:21 -0700, swapnil wrote:

> I could not find any documentation for variables os.path.sep and
> os.path.altsep. Although the first is pretty straightforward can
> anyone explain the purpose of the second variable? Is it even useful?

The purpose is so that you can do e.g.:

	if c == os.path.sep or c == os.path.altsep:
	    ...

On Windows, both '\' and '/' are directory separators; you shouldn't rely
upon a particular one being used, but should check for either.




More information about the Python-list mailing list