python path separator

S

swapnil

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?
According to issue http://bugs.python.org/issue709428, os.path.altsep
was 'None' till a long time and it didn't bother anyone?
 
V

Vlastimil Brom

2010/9/2 swapnil said:
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?
According to issue http://bugs.python.org/issue709428, os.path.altsep
was 'None' till a long time and it didn't bother anyone?
see
http://docs.python.org/library/os.html#os.sep
http://docs.python.org/library/os.html#os.altsep

On windows it returns a slash'/'
which is often easier to use (i.e. if I understand correctly, in most
usual cases the forward slash should probably just work on most of the
recent OSes).

vbr
 
S

swapnil

seehttp://docs.python.org/library/os.html#os.sephttp://docs.python.org/library/os.html#os.altsep

On windows it returns a slash>>> os.altsep

'/'
which is often easier to use (i.e. if I understand correctly, in most
usual cases the forward slash should probably just work on most of the
recent OSes).

   vbr

Thanks for help
 
N

Nobody

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top