Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6699613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:42:57+00:00 2026-05-26T06:42:57+00:00

Under Unix, os.path.normpath collapses multiple slashes into single ones except when exactly two slashes

  • 0

Under Unix, os.path.normpath collapses multiple slashes into single ones except when exactly two slashes appear that the start of the path. Why the 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

This seems strange to me. I can vaguely imagine this is useful for SMB mounts or URLS, but I don’t think I care about those. Is there any hidden wisdom to Python’s behaviour, or should I just collapse the leading // myself?

[update]
In view of the answer below, it looks like the best thing is not to collapse the //, but to either just accept it, or to treat it as an error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T06:42:58+00:00Added an answer on May 26, 2026 at 6:42 am

    Because POSIX allows treating a path beginning with two slashes in an implementation-defined manner. In other words, //foo does not necessarily mean the same thing as /foo on all POSIX systems.

    From IEEE Std 1003.1:

    A pathname that begins with two successive slashes may be interpreted
    in an implementation-defined manner, although more than two leading
    slashes shall be treated as a single slash.

    See also this bug report (which was closed as "not a bug").

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file we will call info.txt under UNIX format that has only
I have a project that should be run forever under unix. But in case
I am working on SAS code that will run under UNIX. Ideally the IDE
I am writing a java program that runs under unix. It would like run
I have two unix partitions under debian which I would like to merge (disk
There are two path separators in common use: the Unix forward-slash and the DOS
I have received a Unix tool that I want to run / compile under
Python's os.path.getctime on the Mac (and under Unix in general) does not give the
I have this code for server code in c, under unix: /* A simple
On a server there are several independent Plone buildout installations, running under different UNIX

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.