os.path.normpath()

Gawain Bolton gbolton at wanadoo.fr
Wed Jan 24 16:21:59 EST 2001


I'm using Python v1.5.2 on Sun and Linux and have noticed what, to me,
is strange behaviour with the os.path.normpath() function.

Namely, I noticed the following:

1. os.path.normpath('///A///B///C///D') gives '///A/B/C/D'

and

2. os.path.normpath('/../A/../A/B') gives '/../A/B'

I'm sure I'm not the first one to notice this, and so I'm assuming this
is "correct".  Could anyone please explain:

A) Why leading slashes are not collapsed into a single slash.
B) Why a leading /../ is not collapsed.

I'm warning you though, I will not buy any platform dependent answers
since the normpath() funciton is implemented in posixpath.py module
which is tailored for POSIX systems (i.e. Unices).

Thanks a bunch,


Gawain





More information about the Python-list mailing list