On Unix, os.path.normpath collapses multiple slashes into single slashes , unless exactly two traits appear that start with the path . Why an exception?
To illustrate, I get the following transformations:
//double/slash/stays -> //double/slash/stays /double/slash//gone// -> /double/slash/gone/ double//slash//gone/ -> double/slash/gone ///triple/slash/gone -> /triple/slash/gone ////quad/slash/gone -> /quad/slash/gone
It seems strange to me. I can vaguely imagine that this is useful for SMB or URLS monsters, but I donβt think I care. Is there any hidden wisdom for Python behavior, or should I just collapse the lead // myself?
[update] In view of the answer below, it seems best not to collapse //, but simply accept it or treat it as an error.
source share