On Wed, Dec 02, 2026 at 10:50:40AM -0700, Jason Friedman via Python-list wrote:
> >
> > This is all on Windows.
> > I was surprised to discover that
> >      os.path.split(".")
> > returns
> >      ('', '.')
> > rather than
> >      ('.', '')
> > i.e. the dot is treated as (part of) a file name rather than a directory
> > name.
> > After all, "." is not a valid file name (though it could be part of a
> > file name) but IS a valid directory name.
> > Is there a good reason for this?
> >
> 
> https://docs.python.org/3/library/os.path.html#os.path.split says:
> Split the pathname path into a pair, (head, tail) ...
> 
> I see your point, but maybe because some find it easier to work with a
> function which returns the same signature regardless of the input?
> 
> FWIW, same results on Linux.
> -- 
> https://mail.python.org/mailman3//lists/python-list.python.org
> 

On a POSIX (Unix) system, the dot file (".") is a special _file_
that refers to the current directory. The _type_ of the dot file is
"directory", i.e., it is not a regular file, socket, named pipe, or any
other type of file.

In the path ".", the filename portion of the path (the "tail") is "."
and the part that leads up to the filename portion (the "head") is "".

Andreas
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to