Lines Matching full:path
13 you want to manipulate paths, see the :mod:`os.path` module, and if you want to
23 interface; for example, the function ``os.stat(path)`` returns stat
24 information about *path* in the same format (which happens to have originated
31 * All functions accepting path or file names accept both bytes and string
32 objects, and result in an object of the same type, if a path or file name is
245 .. function:: chdir(path)
255 Encode :term:`path-like <path-like object>` *filename* to the
270 Decode the :term:`path-like <path-like object>` *filename* from the
283 .. function:: fspath(path)
285 Return the file system representation of the path.
297 An :term:`abstract base class` for objects representing a file system path,
304 Return the file system path representation of the object.
347 to lookup the PATH in.
896 .. audit-event:: os.chmod path,mode,dir_fd os.fchmod
911 .. audit-event:: os.chown path,uid,gid,dir_fd os.fchown
1077 .. function:: open(path, flags, mode=0o777, *, dir_fd=None)
1079 Open the file *path* and set various flags according to *flags* and possibly
1092 .. audit-event:: open path,mode,flags os.open
1113 Accepts a :term:`path-like object`.
1714 Normally the *path* argument provided to functions in the :mod:`os` module
1715 must be a string specifying a file path. However, some functions now
1716 alternatively accept an open file descriptor for their *path* argument.
1721 You can check whether or not *path* can be specified as a file descriptor
1727 an error to specify one of those when supplying *path* as a file descriptor.
1732 should be a file descriptor referring to a directory, and the path to operate
1733 on should be relative; path will then be relative to that directory. If the
1734 path is absolute, *dir_fd* is ignored. (For POSIX systems, Python will call
1745 ``False``, and the last element of the path to operate on is a symbolic link,
1756 .. function:: access(path, mode, *, dir_fd=None, effective_ids=False, follow_symlinks=True)
1758 Use the real uid/gid to test for access to *path*. Note that most operations
1761 *path*. *mode* should be :const:`F_OK` to test the existence of *path*, or it
1809 Accepts a :term:`path-like object`.
1818 existence, readability, writability and executability of *path*,
1822 .. function:: chdir(path)
1826 Change the current working directory to *path*.
1834 .. audit-event:: os.chdir path os.chdir
1837 Added support for specifying *path* as a file descriptor
1841 Accepts a :term:`path-like object`.
1844 .. function:: chflags(path, flags, *, follow_symlinks=True)
1846 Set the flags of *path* to the numeric *flags*. *flags* may take a combination
1864 .. audit-event:: os.chflags path,flags os.chflags
1872 Accepts a :term:`path-like object`.
1875 .. function:: chmod(path, mode, *, dir_fd=None, follow_symlinks=True)
1877 Change the mode of *path* to the numeric *mode*. *mode* may take one of the
1914 .. audit-event:: os.chmod path,mode,dir_fd os.chmod
1917 Added support for specifying *path* as an open file descriptor,
1921 Accepts a :term:`path-like object`.
1924 .. function:: chown(path, uid, gid, *, dir_fd=None, follow_symlinks=True)
1926 Change the owner and group id of *path* to the numeric *uid* and *gid*. To
1936 .. audit-event:: os.chown path,uid,gid,dir_fd os.chown
1944 Added support for specifying *path* as an open file descriptor,
1948 Supports a :term:`path-like object`.
1951 .. function:: chroot(path)
1953 Change the root directory of the current process to *path*.
1958 Accepts a :term:`path-like object`.
1967 .. audit-event:: os.chdir path os.fchdir
1987 .. function:: lchflags(path, flags)
1989 Set the flags of *path* to the numeric *flags*, like :func:`chflags`, but do
1991 ``os.chflags(path, flags, follow_symlinks=False)``.
1993 .. audit-event:: os.chflags path,flags os.lchflags
1998 Accepts a :term:`path-like object`.
2001 .. function:: lchmod(path, mode)
2003 Change the mode of *path* to the numeric *mode*. If path is a symlink, this
2006 ``os.chmod(path, mode, follow_symlinks=False)``.
2008 .. audit-event:: os.chmod path,mode,dir_fd os.lchmod
2013 Accepts a :term:`path-like object`.
2015 .. function:: lchown(path, uid, gid)
2017 Change the owner and group id of *path* to the numeric *uid* and *gid*. This
2019 to ``os.chown(path, uid, gid, follow_symlinks=False)``.
2021 .. audit-event:: os.chown path,uid,gid,dir_fd os.lchown
2026 Accepts a :term:`path-like object`.
2048 Accepts a :term:`path-like object` for *src* and *dst*.
2051 .. function:: listdir(path='.')
2054 *path*. The list is in arbitrary order, and does not include the special
2059 *path* may be a :term:`path-like object`. If *path* is of type ``bytes``
2067 .. audit-event:: os.listdir path os.listdir
2079 The *path* parameter became optional.
2082 Added support for specifying *path* as an open file descriptor.
2085 Accepts a :term:`path-like object`.
2088 .. function:: lstat(path, *, dir_fd=None)
2090 Perform the equivalent of an :c:func:`lstat` system call on the given path.
2097 As of Python 3.3, this is equivalent to ``os.stat(path, dir_fd=dir_fd,
2114 Accepts a :term:`path-like object`.
2117 On Windows, now opens reparse points that represent another path
2123 .. function:: mkdir(path, mode=0o777, *, dir_fd=None)
2125 Create a directory named *path* with numeric mode *mode*.
2128 directory in the path does not exist, :exc:`FileNotFoundError` is raised.
2148 .. audit-event:: os.mkdir path,mode,dir_fd os.mkdir
2154 Accepts a :term:`path-like object`.
2180 :func:`makedirs` will become confused if the path elements to create
2185 .. audit-event:: os.mkdir path,mode,dir_fd os.makedirs
2198 Accepts a :term:`path-like object`.
2205 .. function:: mkfifo(path, mode=0o666, *, dir_fd=None)
2207 Create a FIFO (a named pipe) named *path* with numeric mode *mode*.
2225 Accepts a :term:`path-like object`.
2228 .. function:: mknod(path, mode=0o600, device=0, *, dir_fd=None)
2231 *path*. *mode* specifies both the permissions to use and the type of node
2247 Accepts a :term:`path-like object`.
2267 .. function:: pathconf(path, name)
2288 Accepts a :term:`path-like object`.
2300 .. function:: readlink(path, *, dir_fd=None)
2302 Return a string representing the path to which the symbolic link points. The
2305 ``os.path.join(os.path.dirname(path), result)``.
2307 If the *path* is a string object (directly or indirectly through a
2309 and the call may raise a UnicodeDecodeError. If the *path* is a bytes
2315 When trying to resolve a path that may contain links, use
2316 :func:`~os.path.realpath` to properly handle recursion and platform
2328 Accepts a :term:`path-like object` on Unix.
2331 Accepts a :term:`path-like object` and a bytes object on Windows.
2335 substitution path (which typically includes ``\\?\`` prefix) rather
2338 .. function:: remove(path, *, dir_fd=None)
2340 Remove (delete) the file *path*. If *path* is a directory, an
2353 .. audit-event:: os.remove path,dir_fd os.remove
2359 Accepts a :term:`path-like object`.
2368 successively remove every parent directory mentioned in *path* until an error
2375 .. audit-event:: os.remove path,dir_fd os.removedirs
2378 Accepts a :term:`path-like object`.
2410 Accepts a :term:`path-like object` for *src* and *dst*.
2417 attempted first. After the rename, directories corresponding to rightmost path
2428 Accepts a :term:`path-like object` for *old* and *new*.
2447 Accepts a :term:`path-like object` for *src* and *dst*.
2450 .. function:: rmdir(path, *, dir_fd=None)
2452 Remove (delete) the directory *path*. If the directory does not exist or is
2460 .. audit-event:: os.rmdir path,dir_fd os.rmdir
2466 Accepts a :term:`path-like object`.
2469 .. function:: scandir(path='.')
2472 entries in the directory given by *path*. The entries are yielded in
2488 *path* may be a :term:`path-like object`. If *path* is of type ``bytes``
2490 the type of the :attr:`~os.DirEntry.name` and :attr:`~os.DirEntry.path`
2497 .. audit-event:: os.scandir path os.scandir
2514 the files (excluding directories) in the given *path* that don't start with
2518 with os.scandir(path) as it:
2543 The function accepts a :term:`path-like object`.
2551 Object yielded by :func:`scandir` to expose the file path and other file
2560 elapsed since calling :func:`scandir`, call ``os.stat(entry.path)`` to fetch
2568 To be directly usable as a :term:`path-like object`, ``os.DirEntry``
2575 The entry's base filename, relative to the :func:`scandir` *path*
2579 *path* argument is of type ``bytes`` and ``str`` otherwise. Use
2582 .. attribute:: path
2584 The entry's full path name: equivalent to ``os.path.join(scandir_path,
2585 entry.name)`` where *scandir_path* is the :func:`scandir` *path*
2586 argument. The path is only absolute if the :func:`scandir` *path*
2587 argument was absolute. If the :func:`scandir` *path*
2588 argument was a :ref:`file descriptor <path_fd>`, the :attr:`path`
2591 The :attr:`path` attribute will be ``bytes`` if the :func:`scandir`
2592 *path* argument is of type ``bytes`` and ``str`` otherwise. Use
2600 ``os.stat(entry.path, follow_symlinks=False).st_ino`` to fetch up-to-date
2650 :func:`os.path.islink` to fetch up-to-date information.
2680 and methods of ``os.DirEntry`` and of :class:`pathlib.Path`. In
2692 .. function:: stat(path, *, dir_fd=None, follow_symlinks=True)
2695 :c:func:`stat` system call on the given path. *path* may be specified as
2712 obtain stat results for the final path in this case, use the
2713 :func:`os.path.realpath` function to resolve the path name as far as
2736 descriptor instead of a path.
2739 Accepts a :term:`path-like object`.
2746 returns the information for the original path as if
2950 .. function:: statvfs(path)
2952 Perform a :c:func:`statvfs` system call on the given path. The return value is
2953 an object whose attributes describe the filesystem on the given path, and
2981 Added support for specifying *path* as an open file descriptor.
2990 Accepts a :term:`path-like object`.
3043 :mod:`os` module permit specifying their *path* parameter as an open file
3046 descriptors as *path* arguments is not available on all platforms Python
3050 descriptor for its *path* parameter, use the ``in`` operator on
3052 :func:`os.chdir` accepts open file descriptors for *path* on your local
3122 Accepts a :term:`path-like object` for *src* and *dst*.
3137 .. function:: truncate(path, length)
3139 Truncate the file corresponding to *path*, so that it is at most
3144 .. audit-event:: os.truncate path,length os.truncate
3154 Accepts a :term:`path-like object`.
3157 .. function:: unlink(path, *, dir_fd=None)
3159 Remove (delete) the file *path*. This function is semantically
3164 .. audit-event:: os.remove path,dir_fd os.unlink
3170 Accepts a :term:`path-like object`.
3173 .. function:: utime(path, times=None, *[, ns], dir_fd=None, follow_symlinks=True)
3175 Set the access and modified times of the file specified by *path*.
3178 These specify the times set on *path* and are used as follows:
3203 .. audit-event:: os.utime path,times,ns,dir_fd os.utime
3206 Added support for specifying *path* as an open file descriptor,
3210 Accepts a :term:`path-like object`.
3224 *dirpath* is a string, the path to the directory. *dirnames* is a list of the
3228 Note that the names in the lists contain no path components. To get a full path
3230 ``os.path.join(dirpath, name)``. Whether or not the lists are sorted
3279 from os.path import join, getsize
3298 os.remove(os.path.join(root, name))
3300 os.rmdir(os.path.join(root, name))
3309 Accepts a :term:`path-like object`.
3370 Accepts a :term:`path-like object`.
3525 .. function:: getxattr(path, attribute, *, follow_symlinks=True)
3528 *path*. *attribute* can be bytes or str (directly or indirectly through the
3535 .. audit-event:: os.getxattr path,attribute os.getxattr
3538 Accepts a :term:`path-like object` for *path* and *attribute*.
3541 .. function:: listxattr(path=None, *, follow_symlinks=True)
3543 Return a list of the extended filesystem attributes on *path*. The
3545 encoding. If *path* is ``None``, :func:`listxattr` will examine the current
3551 .. audit-event:: os.listxattr path os.listxattr
3554 Accepts a :term:`path-like object`.
3557 .. function:: removexattr(path, attribute, *, follow_symlinks=True)
3559 Removes the extended filesystem attribute *attribute* from *path*.
3567 .. audit-event:: os.removexattr path,attribute os.removexattr
3570 Accepts a :term:`path-like object` for *path* and *attribute*.
3573 .. function:: setxattr(path, attribute, value, flags=0, *, follow_symlinks=True)
3575 Set the extended filesystem attribute *attribute* on *path* to *value*.
3592 .. audit-event:: os.setxattr path,attribute,value,flags os.setxattr
3595 Accepts a :term:`path-like object` for *path* and *attribute*.
3641 .. function:: add_dll_directory(path)
3643 Add a path to the DLL search path.
3645 This search path is used when resolving dependencies for imported
3647 :data:`sys.path`), and also by :mod:`ctypes`.
3656 .. audit-event:: os.add_dll_directory path os.add_dll_directory
3663 such as only sometimes searching :envvar:`PATH` or the current
3673 .. function:: execl(path, arg0, arg1, ...)
3674 execle(path, arg0, arg1, ..., env)
3677 execv(path, args)
3678 execve(path, args, env)
3704 :envvar:`PATH` environment variable to locate the program *file*. When the
3707 the :envvar:`PATH` variable. The other variants, :func:`execl`, :func:`execle`,
3708 :func:`execv`, and :func:`execve`, will not use the :envvar:`PATH` variable to
3709 locate the executable; *path* must contain an appropriate absolute or relative
3710 path.
3719 For :func:`execve` on some platforms, *path* may also be specified as an open
3724 .. audit-event:: os.exec path,args,env os.execl
3729 Added support for specifying *path* as an open file descriptor
3733 Accepts a :term:`path-like object`.
4029 .. function:: posix_spawn(path, argv, env, *, file_actions=None, \
4037 The positional-only arguments *path*, *args*, and *env* are similar to
4040 The *path* parameter is the path to the executable file. The *path* should
4052 (``os.POSIX_SPAWN_OPEN``, *fd*, *path*, *flags*, *mode*)
4054 Performs ``os.dup2(os.open(path, flags, mode), fd)``.
4109 .. audit-event:: os.posix_spawn path,argv,env os.posix_spawn
4115 .. function:: posix_spawnp(path, argv, env, *, file_actions=None, \
4123 :envvar:`PATH` environment variable (in the same way as for ``execvp(3)``).
4125 .. audit-event:: os.posix_spawn path,argv,env os.posix_spawnp
4167 .. function:: spawnl(mode, path, ...)
4168 spawnle(mode, path, ..., env)
4171 spawnv(mode, path, args)
4172 spawnve(mode, path, args, env)
4176 Execute the program *path* in a new process.
4203 :envvar:`PATH` environment variable to locate the program *file*. When the
4206 the :envvar:`PATH` variable. The other variants, :func:`spawnl`,
4208 :envvar:`PATH` variable to locate the executable; *path* must contain an
4209 appropriate absolute or relative path.
4229 .. audit-event:: os.spawn mode,path,args,env os.spawnl
4239 Accepts a :term:`path-like object`.
4276 .. function:: startfile(path, [operation], [arguments], [cwd], [show_cmd])
4295 argument. This should be an absolute path. A relative *path* will be resolved
4304 the application's exit status. The *path* parameter is relative to the current
4305 directory or *cwd*. If you want to use an absolute path, make sure the first
4307 :func:`os.path.normpath` function to ensure that paths are properly encoded for
4314 .. audit-event:: os.startfile path,operation os.startfile
4316 .. audit-event:: os.startfile/2 path,operation,arguments,cwd,show_cmd os.startfile
4844 .. _os-path:
4922 The following data values are used to support path manipulation operations. These
4925 Higher-level operations on pathnames are defined in the :mod:`os.path` module.
4933 :mod:`os.path`.
4941 :mod:`os.path`.
4951 :func:`os.path.split` and :func:`os.path.join` --- but it is occasionally
4952 useful. Also available via :mod:`os.path`.
4961 :mod:`os.path`.
4968 the ``'.'`` in :file:`os.py`. Also available via :mod:`os.path`.
4971 .. index:: single: : (colon); path separator (POSIX)
4976 path components (as in :envvar:`PATH`), such as ``':'`` for POSIX or ``';'`` for
4977 Windows. Also available via :mod:`os.path`.
4982 The default search path used by :func:`exec\*p\* <execl>` and
4983 :func:`spawn\*p\* <spawnl>` if the environment doesn't have a ``'PATH'``
4984 key. Also available via :mod:`os.path`.
4998 The file path of the null device. For example: ``'/dev/null'`` for
4999 POSIX, ``'nul'`` for Windows. Also available via :mod:`os.path`.