Why does python have os.path.curdir

It is a constant, just like os.path.sep.

Platforms other than POSIX and Windows could use a different value to denote the ‘current directory’. On Risc OS it’s @ for example, on the old Macintosh OS it’s :.

The value is used throughout the standard library to remain platform agnostic.

Use os.getcwd() instead; os.path.abspath() uses that function under the hood to turn os.path.curdir into the current working directory anyway. Here is the POSIX implementation of abspath():

def abspath(path):
    """Return an absolute path."""
    if not isabs(path):
        if isinstance(path, _unicode):
            cwd = os.getcwdu()
        else:
            cwd = os.getcwd()
        path = join(cwd, path)
    return normpath(path)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)