doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
shlex.quote(s) Return a shell-escaped version of the string s. The returned value is a string that can safely be used as one token in a shell command line, for cases where you cannot use a list. This idiom would be unsafe: >>> filename = 'somefile; rm -rf ~' >>> command = 'ls -l {}'.format(filename) >>> print(command...
python.library.shlex#shlex.quote
class shlex.shlex(instream=None, infile=None, posix=False, punctuation_chars=False) A shlex instance or subclass instance is a lexical analyzer object. The initialization argument, if present, specifies where to read characters from. It must be a file-/stream-like object with read() and readline() methods, or a strin...
python.library.shlex#shlex.shlex
shlex.commenters The string of characters that are recognized as comment beginners. All characters from the comment beginner to end of line are ignored. Includes just '#' by default.
python.library.shlex#shlex.shlex.commenters
shlex.debug If this attribute is numeric and 1 or more, a shlex instance will print verbose progress output on its behavior. If you need to use this, you can read the module source code to learn the details.
python.library.shlex#shlex.shlex.debug
shlex.eof Token used to determine end of file. This will be set to the empty string (''), in non-POSIX mode, and to None in POSIX mode.
python.library.shlex#shlex.shlex.eof
shlex.error_leader(infile=None, lineno=None) This method generates an error message leader in the format of a Unix C compiler error label; the format is '"%s", line %d: ', where the %s is replaced with the name of the current source file and the %d with the current input line number (the optional arguments can be use...
python.library.shlex#shlex.shlex.error_leader
shlex.escape Characters that will be considered as escape. This will be only used in POSIX mode, and includes just '\' by default.
python.library.shlex#shlex.shlex.escape
shlex.escapedquotes Characters in quotes that will interpret escape characters defined in escape. This is only used in POSIX mode, and includes just '"' by default.
python.library.shlex#shlex.shlex.escapedquotes
shlex.get_token() Return a token. If tokens have been stacked using push_token(), pop a token off the stack. Otherwise, read one from the input stream. If reading encounters an immediate end-of-file, eof is returned (the empty string ('') in non-POSIX mode, and None in POSIX mode).
python.library.shlex#shlex.shlex.get_token
shlex.infile The name of the current input file, as initially set at class instantiation time or stacked by later source requests. It may be useful to examine this when constructing error messages.
python.library.shlex#shlex.shlex.infile
shlex.instream The input stream from which this shlex instance is reading characters.
python.library.shlex#shlex.shlex.instream
shlex.lineno Source line number (count of newlines seen so far plus one).
python.library.shlex#shlex.shlex.lineno
shlex.pop_source() Pop the last-pushed input source from the input stack. This is the same method used internally when the lexer reaches EOF on a stacked input stream.
python.library.shlex#shlex.shlex.pop_source
shlex.punctuation_chars A read-only property. Characters that will be considered punctuation. Runs of punctuation characters will be returned as a single token. However, note that no semantic validity checking will be performed: for example, ‘>>>’ could be returned as a token, even though it may not be recognised as ...
python.library.shlex#shlex.shlex.punctuation_chars
shlex.push_source(newstream, newfile=None) Push an input source stream onto the input stack. If the filename argument is specified it will later be available for use in error messages. This is the same method used internally by the sourcehook() method.
python.library.shlex#shlex.shlex.push_source
shlex.push_token(str) Push the argument onto the token stack.
python.library.shlex#shlex.shlex.push_token
shlex.quotes Characters that will be considered string quotes. The token accumulates until the same quote is encountered again (thus, different quote types protect each other as in the shell.) By default, includes ASCII single and double quotes.
python.library.shlex#shlex.shlex.quotes
shlex.read_token() Read a raw token. Ignore the pushback stack, and do not interpret source requests. (This is not ordinarily a useful entry point, and is documented here only for the sake of completeness.)
python.library.shlex#shlex.shlex.read_token
shlex.source This attribute is None by default. If you assign a string to it, that string will be recognized as a lexical-level inclusion request similar to the source keyword in various shells. That is, the immediately following token will be opened as a filename and input will be taken from that stream until EOF, a...
python.library.shlex#shlex.shlex.source
shlex.sourcehook(filename) When shlex detects a source request (see source below) this method is given the following token as argument, and expected to return a tuple consisting of a filename and an open file-like object. Normally, this method first strips any quotes off the argument. If the result is an absolute pat...
python.library.shlex#shlex.shlex.sourcehook
shlex.token The token buffer. It may be useful to examine this when catching exceptions.
python.library.shlex#shlex.shlex.token
shlex.whitespace Characters that will be considered whitespace and skipped. Whitespace bounds tokens. By default, includes space, tab, linefeed and carriage-return.
python.library.shlex#shlex.shlex.whitespace
shlex.whitespace_split If True, tokens will only be split in whitespaces. This is useful, for example, for parsing command lines with shlex, getting tokens in a similar way to shell arguments. When used in combination with punctuation_chars, tokens will be split on whitespace in addition to those characters. Changed...
python.library.shlex#shlex.shlex.whitespace_split
shlex.wordchars The string of characters that will accumulate into multi-character tokens. By default, includes all ASCII alphanumerics and underscore. In POSIX mode, the accented characters in the Latin-1 set are also included. If punctuation_chars is not empty, the characters ~-./*?=, which can appear in filename s...
python.library.shlex#shlex.shlex.wordchars
shlex.split(s, comments=False, posix=True) Split the string s using shell-like syntax. If comments is False (the default), the parsing of comments in the given string will be disabled (setting the commenters attribute of the shlex instance to the empty string). This function operates in POSIX mode by default, but use...
python.library.shlex#shlex.split
shutil — High-level file operations Source code: Lib/shutil.py The shutil module offers a number of high-level operations on files and collections of files. In particular, functions are provided which support file copying and removal. For operations on individual files, see also the os module. Warning Even the higher-...
python.library.shutil
shutil.chown(path, user=None, group=None) Change owner user and/or group of the given path. user can be a system user name or a uid; the same applies to group. At least one argument is required. See also os.chown(), the underlying function. Raises an auditing event shutil.chown with arguments path, user, group. Avail...
python.library.shutil#shutil.chown
shutil.copy(src, dst, *, follow_symlinks=True) Copies the file src to the file or directory dst. src and dst should be path-like objects or strings. If dst specifies a directory, the file will be copied into dst using the base filename from src. Returns the path to the newly created file. If follow_symlinks is false,...
python.library.shutil#shutil.copy
shutil.copy2(src, dst, *, follow_symlinks=True) Identical to copy() except that copy2() also attempts to preserve file metadata. When follow_symlinks is false, and src is a symbolic link, copy2() attempts to copy all metadata from the src symbolic link to the newly-created dst symbolic link. However, this functionali...
python.library.shutil#shutil.copy2
shutil.copyfile(src, dst, *, follow_symlinks=True) Copy the contents (no metadata) of the file named src to a file named dst and return dst in the most efficient way possible. src and dst are path-like objects or path names given as strings. dst must be the complete target file name; look at copy() for a copy that ac...
python.library.shutil#shutil.copyfile
shutil.copyfileobj(fsrc, fdst[, length]) Copy the contents of the file-like object fsrc to the file-like object fdst. The integer length, if given, is the buffer size. In particular, a negative length value means to copy the data without looping over the source data in chunks; by default the data is read in chunks to...
python.library.shutil#shutil.copyfileobj
shutil.copymode(src, dst, *, follow_symlinks=True) Copy the permission bits from src to dst. The file contents, owner, and group are unaffected. src and dst are path-like objects or path names given as strings. If follow_symlinks is false, and both src and dst are symbolic links, copymode() will attempt to modify the...
python.library.shutil#shutil.copymode
shutil.copystat(src, dst, *, follow_symlinks=True) Copy the permission bits, last access time, last modification time, and flags from src to dst. On Linux, copystat() also copies the “extended attributes” where possible. The file contents, owner, and group are unaffected. src and dst are path-like objects or path nam...
python.library.shutil#shutil.copystat
shutil.copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2, ignore_dangling_symlinks=False, dirs_exist_ok=False) Recursively copy an entire directory tree rooted at src to a directory named dst and return the destination directory. dirs_exist_ok dictates whether to raise an exception in case dst or an...
python.library.shutil#shutil.copytree
shutil.disk_usage(path) Return disk usage statistics about the given path as a named tuple with the attributes total, used and free, which are the amount of total, used and free space, in bytes. path may be a file or a directory. New in version 3.3. Changed in version 3.8: On Windows, path can now be a file or dir...
python.library.shutil#shutil.disk_usage
exception shutil.Error This exception collects exceptions that are raised during a multi-file operation. For copytree(), the exception argument is a list of 3-tuples (srcname, dstname, exception).
python.library.shutil#shutil.Error
shutil.get_archive_formats() Return a list of supported formats for archiving. Each element of the returned sequence is a tuple (name, description). By default shutil provides these formats: zip: ZIP file (if the zlib module is available). tar: Uncompressed tar file. Uses POSIX.1-2001 pax format for new archives. ...
python.library.shutil#shutil.get_archive_formats
shutil.get_terminal_size(fallback=(columns, lines)) Get the size of the terminal window. For each of the two dimensions, the environment variable, COLUMNS and LINES respectively, is checked. If the variable is defined and the value is a positive integer, it is used. When COLUMNS or LINES is not defined, which is the ...
python.library.shutil#shutil.get_terminal_size
shutil.get_unpack_formats() Return a list of all registered formats for unpacking. Each element of the returned sequence is a tuple (name, extensions, description). By default shutil provides these formats: zip: ZIP file (unpacking compressed files works only if the corresponding module is available). tar: uncompr...
python.library.shutil#shutil.get_unpack_formats
shutil.ignore_patterns(*patterns) This factory function creates a function that can be used as a callable for copytree()’s ignore argument, ignoring files and directories that match one of the glob-style patterns provided. See the example below.
python.library.shutil#shutil.ignore_patterns
shutil.make_archive(base_name, format[, root_dir[, base_dir[, verbose[, dry_run[, owner[, group[, logger]]]]]]]) Create an archive file (such as zip or tar) and return its name. base_name is the name of the file to create, including the path, minus any format-specific extension. format is the archive format: one of “...
python.library.shutil#shutil.make_archive
shutil.move(src, dst, copy_function=copy2) Recursively move a file or directory (src) to another location (dst) and return the destination. If the destination is an existing directory, then src is moved inside that directory. If the destination already exists but is not a directory, it may be overwritten depending on...
python.library.shutil#shutil.move
shutil.register_archive_format(name, function[, extra_args[, description]]) Register an archiver for the format name. function is the callable that will be used to unpack archives. The callable will receive the base_name of the file to create, followed by the base_dir (which defaults to os.curdir) to start archiving ...
python.library.shutil#shutil.register_archive_format
shutil.register_unpack_format(name, extensions, function[, extra_args[, description]]) Registers an unpack format. name is the name of the format and extensions is a list of extensions corresponding to the format, like .zip for Zip files. function is the callable that will be used to unpack archives. The callable wil...
python.library.shutil#shutil.register_unpack_format
shutil.rmtree(path, ignore_errors=False, onerror=None) Delete an entire directory tree; path must point to a directory (but not a symbolic link to a directory). If ignore_errors is true, errors resulting from failed removals will be ignored; if false or omitted, such errors are handled by calling a handler specified ...
python.library.shutil#shutil.rmtree
rmtree.avoids_symlink_attacks Indicates whether the current platform and implementation provides a symlink attack resistant version of rmtree(). Currently this is only true for platforms supporting fd-based directory access functions. New in version 3.3.
python.library.shutil#shutil.rmtree.avoids_symlink_attacks
exception shutil.SameFileError This exception is raised if source and destination in copyfile() are the same file. New in version 3.4.
python.library.shutil#shutil.SameFileError
shutil.unpack_archive(filename[, extract_dir[, format]]) Unpack an archive. filename is the full path of the archive. extract_dir is the name of the target directory where the archive is unpacked. If not provided, the current working directory is used. format is the archive format: one of “zip”, “tar”, “gztar”, “bzta...
python.library.shutil#shutil.unpack_archive
shutil.unregister_archive_format(name) Remove the archive format name from the list of supported formats.
python.library.shutil#shutil.unregister_archive_format
shutil.unregister_unpack_format(name) Unregister an unpack format. name is the name of the format.
python.library.shutil#shutil.unregister_unpack_format
shutil.which(cmd, mode=os.F_OK | os.X_OK, path=None) Return the path to an executable which would be run if the given cmd was called. If no cmd would be called, return None. mode is a permission mask passed to os.access(), by default determining if the file exists and executable. When no path is specified, the result...
python.library.shutil#shutil.which
signal — Set handlers for asynchronous events This module provides mechanisms to use signal handlers in Python. General rules The signal.signal() function allows defining custom handlers to be executed when a signal is received. A small number of default handlers are installed: SIGPIPE is ignored (so write errors on pi...
python.library.signal
signal.alarm(time) If time is non-zero, this function requests that a SIGALRM signal be sent to the process in time seconds. Any previously scheduled alarm is canceled (only one alarm can be scheduled at any time). The returned value is then the number of seconds before any previously set alarm was to have been deliv...
python.library.signal#signal.alarm
signal.CTRL_BREAK_EVENT The signal corresponding to the Ctrl+Break keystroke event. This signal can only be used with os.kill(). Availability: Windows. New in version 3.2.
python.library.signal#signal.CTRL_BREAK_EVENT
signal.CTRL_C_EVENT The signal corresponding to the Ctrl+C keystroke event. This signal can only be used with os.kill(). Availability: Windows. New in version 3.2.
python.library.signal#signal.CTRL_C_EVENT
signal.getitimer(which) Returns current value of a given interval timer specified by which. Availability: Unix.
python.library.signal#signal.getitimer
signal.getsignal(signalnum) Return the current signal handler for the signal signalnum. The returned value may be a callable Python object, or one of the special values signal.SIG_IGN, signal.SIG_DFL or None. Here, signal.SIG_IGN means that the signal was previously ignored, signal.SIG_DFL means that the default way ...
python.library.signal#signal.getsignal
exception signal.ItimerError Raised to signal an error from the underlying setitimer() or getitimer() implementation. Expect this error if an invalid interval timer or a negative time is passed to setitimer(). This error is a subtype of OSError. New in version 3.3: This error used to be a subtype of IOError, which i...
python.library.signal#signal.ItimerError
signal.ITIMER_PROF Decrements interval timer both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration.
python.library.signal#signal.ITIMER_PROF
signal.ITIMER_REAL Decrements interval timer in real time, and delivers SIGALRM upon expiration.
python.library.signal#signal.ITIMER_REAL
signal.ITIMER_VIRTUAL Decrements interval timer only when the process is executing, and delivers SIGVTALRM upon expiration.
python.library.signal#signal.ITIMER_VIRTUAL
signal.NSIG One more than the number of the highest signal number.
python.library.signal#signal.NSIG
signal.pause() Cause the process to sleep until a signal is received; the appropriate handler will then be called. Returns nothing. Availability: Unix. See the man page signal(2) for further information. See also sigwait(), sigwaitinfo(), sigtimedwait() and sigpending().
python.library.signal#signal.pause
signal.pidfd_send_signal(pidfd, sig, siginfo=None, flags=0) Send signal sig to the process referred to by file descriptor pidfd. Python does not currently support the siginfo parameter; it must be None. The flags argument is provided for future extensions; no flag values are currently defined. See the pidfd_send_sign...
python.library.signal#signal.pidfd_send_signal
signal.pthread_kill(thread_id, signalnum) Send the signal signalnum to the thread thread_id, another thread in the same process as the caller. The target thread can be executing any code (Python or not). However, if the target thread is executing the Python interpreter, the Python signal handlers will be executed by ...
python.library.signal#signal.pthread_kill
signal.pthread_sigmask(how, mask) Fetch and/or change the signal mask of the calling thread. The signal mask is the set of signals whose delivery is currently blocked for the caller. Return the old signal mask as a set of signals. The behavior of the call is dependent on the value of how, as follows. SIG_BLOCK: The...
python.library.signal#signal.pthread_sigmask
signal.raise_signal(signum) Sends a signal to the calling process. Returns nothing. New in version 3.8.
python.library.signal#signal.raise_signal
signal.setitimer(which, seconds, interval=0.0) Sets given interval timer (one of signal.ITIMER_REAL, signal.ITIMER_VIRTUAL or signal.ITIMER_PROF) specified by which to fire after seconds (float is accepted, different from alarm()) and after that every interval seconds (if interval is non-zero). The interval timer spe...
python.library.signal#signal.setitimer
signal.set_wakeup_fd(fd, *, warn_on_full_buffer=True) Set the wakeup file descriptor to fd. When a signal is received, the signal number is written as a single byte into the fd. This can be used by a library to wakeup a poll or select call, allowing the signal to be fully processed. The old wakeup fd is returned (or ...
python.library.signal#signal.set_wakeup_fd
signal.SIGABRT Abort signal from abort(3).
python.library.signal#signal.SIGABRT
signal.SIGALRM Timer signal from alarm(2). Availability: Unix.
python.library.signal#signal.SIGALRM
signal.SIGBREAK Interrupt from keyboard (CTRL + BREAK). Availability: Windows.
python.library.signal#signal.SIGBREAK
signal.SIGBUS Bus error (bad memory access). Availability: Unix.
python.library.signal#signal.SIGBUS
signal.SIGCHLD Child process stopped or terminated. Availability: Unix.
python.library.signal#signal.SIGCHLD
signal.SIGCLD Alias to SIGCHLD.
python.library.signal#signal.SIGCLD
signal.SIGCONT Continue the process if it is currently stopped Availability: Unix.
python.library.signal#signal.SIGCONT
signal.SIGFPE Floating-point exception. For example, division by zero. See also ZeroDivisionError is raised when the second argument of a division or modulo operation is zero.
python.library.signal#signal.SIGFPE
signal.SIGHUP Hangup detected on controlling terminal or death of controlling process. Availability: Unix.
python.library.signal#signal.SIGHUP
signal.SIGILL Illegal instruction.
python.library.signal#signal.SIGILL
signal.SIGINT Interrupt from keyboard (CTRL + C). Default action is to raise KeyboardInterrupt.
python.library.signal#signal.SIGINT
signal.siginterrupt(signalnum, flag) Change system call restart behaviour: if flag is False, system calls will be restarted when interrupted by signal signalnum, otherwise system calls will be interrupted. Returns nothing. Availability: Unix. See the man page siginterrupt(3) for further information. Note that install...
python.library.signal#signal.siginterrupt
signal.SIGKILL Kill signal. It cannot be caught, blocked, or ignored. Availability: Unix.
python.library.signal#signal.SIGKILL
signal.signal(signalnum, handler) Set the handler for signal signalnum to the function handler. handler can be a callable Python object taking two arguments (see below), or one of the special values signal.SIG_IGN or signal.SIG_DFL. The previous signal handler will be returned (see the description of getsignal() abov...
python.library.signal#signal.signal
signal.sigpending() Examine the set of signals that are pending for delivery to the calling thread (i.e., the signals which have been raised while blocked). Return the set of the pending signals. Availability: Unix. See the man page sigpending(2) for further information. See also pause(), pthread_sigmask() and sigwai...
python.library.signal#signal.sigpending
signal.SIGPIPE Broken pipe: write to pipe with no readers. Default action is to ignore the signal. Availability: Unix.
python.library.signal#signal.SIGPIPE
signal.SIGSEGV Segmentation fault: invalid memory reference.
python.library.signal#signal.SIGSEGV
signal.SIGTERM Termination signal.
python.library.signal#signal.SIGTERM
signal.sigtimedwait(sigset, timeout) Like sigwaitinfo(), but takes an additional timeout argument specifying a timeout. If timeout is specified as 0, a poll is performed. Returns None if a timeout occurs. Availability: Unix. See the man page sigtimedwait(2) for further information. See also pause(), sigwait() and sig...
python.library.signal#signal.sigtimedwait
signal.SIGUSR1 User-defined signal 1. Availability: Unix.
python.library.signal#signal.SIGUSR1
signal.SIGUSR2 User-defined signal 2. Availability: Unix.
python.library.signal#signal.SIGUSR2
signal.sigwait(sigset) Suspend execution of the calling thread until the delivery of one of the signals specified in the signal set sigset. The function accepts the signal (removes it from the pending list of signals), and returns the signal number. Availability: Unix. See the man page sigwait(3) for further informat...
python.library.signal#signal.sigwait
signal.sigwaitinfo(sigset) Suspend execution of the calling thread until the delivery of one of the signals specified in the signal set sigset. The function accepts the signal and removes it from the pending list of signals. If one of the signals in sigset is already pending for the calling thread, the function will ...
python.library.signal#signal.sigwaitinfo
signal.SIGWINCH Window resize signal. Availability: Unix.
python.library.signal#signal.SIGWINCH
signal.SIG_BLOCK A possible value for the how parameter to pthread_sigmask() indicating that signals are to be blocked. New in version 3.3.
python.library.signal#signal.SIG_BLOCK
signal.SIG_DFL This is one of two standard signal handling options; it will simply perform the default function for the signal. For example, on most systems the default action for SIGQUIT is to dump core and exit, while the default action for SIGCHLD is to simply ignore it.
python.library.signal#signal.SIG_DFL
signal.SIG_IGN This is another standard signal handler, which will simply ignore the given signal.
python.library.signal#signal.SIG_IGN
signal.SIG_SETMASK A possible value for the how parameter to pthread_sigmask() indicating that the signal mask is to be replaced. New in version 3.3.
python.library.signal#signal.SIG_SETMASK
signal.SIG_UNBLOCK A possible value for the how parameter to pthread_sigmask() indicating that signals are to be unblocked. New in version 3.3.
python.library.signal#signal.SIG_UNBLOCK
signal.strsignal(signalnum) Return the system description of the signal signalnum, such as “Interrupt”, “Segmentation fault”, etc. Returns None if the signal is not recognized. New in version 3.8.
python.library.signal#signal.strsignal
signal.valid_signals() Return the set of valid signal numbers on this platform. This can be less than range(1, NSIG) if some signals are reserved by the system for internal use. New in version 3.8.
python.library.signal#signal.valid_signals