doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
str.swapcase() Return a copy of the string with uppercase characters converted to lowercase and vice versa. Note that it is not necessarily true that s.swapcase().swapcase() == s.
python.library.stdtypes#str.swapcase
str.title() Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase. For example: >>> 'Hello world'.title() 'Hello World' The algorithm uses a simple language-independent definition of a word as groups of consecutive letters. The definition w...
python.library.stdtypes#str.title
str.translate(table) Return a copy of the string in which each character has been mapped through the given translation table. The table must be an object that implements indexing via __getitem__(), typically a mapping or sequence. When indexed by a Unicode ordinal (an integer), the table object can do any of the foll...
python.library.stdtypes#str.translate
str.upper() Return a copy of the string with all the cased characters 4 converted to uppercase. Note that s.upper().isupper() might be False if s contains uncased characters or if the Unicode category of the resulting character(s) is not “Lu” (Letter, uppercase), but e.g. “Lt” (Letter, titlecase). The uppercasing alg...
python.library.stdtypes#str.upper
str.zfill(width) Return a copy of the string left filled with ASCII '0' digits to make a string of length width. A leading sign prefix ('+'/'-') is handled by inserting the padding after the sign character rather than before. The original string is returned if width is less than or equal to len(s). For example: >>> "...
python.library.stdtypes#str.zfill
Streams Source code: Lib/asyncio/streams.py Streams are high-level async/await-ready primitives to work with network connections. Streams allow sending and receiving data without using callbacks or low-level protocols and transports. Here is an example of a TCP echo client written using asyncio streams: import asyncio ...
python.library.asyncio-stream
string — Common string operations Source code: Lib/string.py See also Text Sequence Type — str String Methods String constants The constants defined in this module are: string.ascii_letters The concatenation of the ascii_lowercase and ascii_uppercase constants described below. This value is not locale-dependent. ...
python.library.string
string.ascii_letters The concatenation of the ascii_lowercase and ascii_uppercase constants described below. This value is not locale-dependent.
python.library.string#string.ascii_letters
string.ascii_lowercase The lowercase letters 'abcdefghijklmnopqrstuvwxyz'. This value is not locale-dependent and will not change.
python.library.string#string.ascii_lowercase
string.ascii_uppercase The uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'. This value is not locale-dependent and will not change.
python.library.string#string.ascii_uppercase
string.capwords(s, sep=None) Split the argument into words using str.split(), capitalize each word using str.capitalize(), and join the capitalized words using str.join(). If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing white...
python.library.string#string.capwords
string.digits The string '0123456789'.
python.library.string#string.digits
class string.Formatter The Formatter class has the following public methods: format(format_string, /, *args, **kwargs) The primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. It is just a wrapper that calls vformat(). Changed in version 3.7: A format string argu...
python.library.string#string.Formatter
check_unused_args(used_args, args, kwargs) Implement checking for unused arguments if desired. The arguments to this function is the set of all argument keys that were actually referred to in the format string (integers for positional arguments, and strings for named arguments), and a reference to the args and kwargs...
python.library.string#string.Formatter.check_unused_args
convert_field(value, conversion) Converts the value (returned by get_field()) given a conversion type (as in the tuple returned by the parse() method). The default version understands ‘s’ (str), ‘r’ (repr) and ‘a’ (ascii) conversion types.
python.library.string#string.Formatter.convert_field
format(format_string, /, *args, **kwargs) The primary API method. It takes a format string and an arbitrary set of positional and keyword arguments. It is just a wrapper that calls vformat(). Changed in version 3.7: A format string argument is now positional-only.
python.library.string#string.Formatter.format
format_field(value, format_spec) format_field() simply calls the global format() built-in. The method is provided so that subclasses can override it.
python.library.string#string.Formatter.format_field
get_field(field_name, args, kwargs) Given field_name as returned by parse() (see above), convert it to an object to be formatted. Returns a tuple (obj, used_key). The default version takes strings of the form defined in PEP 3101, such as “0[name]” or “label.title”. args and kwargs are as passed in to vformat(). The r...
python.library.string#string.Formatter.get_field
get_value(key, args, kwargs) Retrieve a given field value. The key argument will be either an integer or a string. If it is an integer, it represents the index of the positional argument in args; if it is a string, then it represents a named argument in kwargs. The args parameter is set to the list of positional argu...
python.library.string#string.Formatter.get_value
parse(format_string) Loop over the format_string and return an iterable of tuples (literal_text, field_name, format_spec, conversion). This is used by vformat() to break the string into either literal text, or replacement fields. The values in the tuple conceptually represent a span of literal text followed by a sing...
python.library.string#string.Formatter.parse
vformat(format_string, args, kwargs) This function does the actual work of formatting. It is exposed as a separate function for cases where you want to pass in a predefined dictionary of arguments, rather than unpacking and repacking the dictionary as individual arguments using the *args and **kwargs syntax. vformat(...
python.library.string#string.Formatter.vformat
string.hexdigits The string '0123456789abcdefABCDEF'.
python.library.string#string.hexdigits
string.octdigits The string '01234567'.
python.library.string#string.octdigits
string.printable String of ASCII characters which are considered printable. This is a combination of digits, ascii_letters, punctuation, and whitespace.
python.library.string#string.printable
string.punctuation String of ASCII characters which are considered punctuation characters in the C locale: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~.
python.library.string#string.punctuation
class string.Template(template) The constructor takes a single argument which is the template string. substitute(mapping={}, /, **kwds) Performs the template substitution, returning a new string. mapping is any dictionary-like object with keys that match the placeholders in the template. Alternatively, you can pr...
python.library.string#string.Template
safe_substitute(mapping={}, /, **kwds) Like substitute(), except that if placeholders are missing from mapping and kwds, instead of raising a KeyError exception, the original placeholder will appear in the resulting string intact. Also, unlike with substitute(), any other appearances of the $ will simply return $ ins...
python.library.string#string.Template.safe_substitute
substitute(mapping={}, /, **kwds) Performs the template substitution, returning a new string. mapping is any dictionary-like object with keys that match the placeholders in the template. Alternatively, you can provide keyword arguments, where the keywords are the placeholders. When both mapping and kwds are given and...
python.library.string#string.Template.substitute
template This is the object passed to the constructor’s template argument. In general, you shouldn’t change it, but read-only access is not enforced.
python.library.string#string.Template.template
string.whitespace A string containing all ASCII characters that are considered whitespace. This includes the characters space, tab, linefeed, return, formfeed, and vertical tab.
python.library.string#string.whitespace
stringprep — Internet String Preparation Source code: Lib/stringprep.py When identifying things (such as host names) in the internet, it is often necessary to compare such identifications for “equality”. Exactly how this comparison is executed may depend on the application domain, e.g. whether it should be case-insensi...
python.library.stringprep
stringprep.in_table_a1(code) Determine whether code is in tableA.1 (Unassigned code points in Unicode 3.2).
python.library.stringprep#stringprep.in_table_a1
stringprep.in_table_b1(code) Determine whether code is in tableB.1 (Commonly mapped to nothing).
python.library.stringprep#stringprep.in_table_b1
stringprep.in_table_c11(code) Determine whether code is in tableC.1.1 (ASCII space characters).
python.library.stringprep#stringprep.in_table_c11
stringprep.in_table_c11_c12(code) Determine whether code is in tableC.1 (Space characters, union of C.1.1 and C.1.2).
python.library.stringprep#stringprep.in_table_c11_c12
stringprep.in_table_c12(code) Determine whether code is in tableC.1.2 (Non-ASCII space characters).
python.library.stringprep#stringprep.in_table_c12
stringprep.in_table_c21(code) Determine whether code is in tableC.2.1 (ASCII control characters).
python.library.stringprep#stringprep.in_table_c21
stringprep.in_table_c21_c22(code) Determine whether code is in tableC.2 (Control characters, union of C.2.1 and C.2.2).
python.library.stringprep#stringprep.in_table_c21_c22
stringprep.in_table_c22(code) Determine whether code is in tableC.2.2 (Non-ASCII control characters).
python.library.stringprep#stringprep.in_table_c22
stringprep.in_table_c3(code) Determine whether code is in tableC.3 (Private use).
python.library.stringprep#stringprep.in_table_c3
stringprep.in_table_c4(code) Determine whether code is in tableC.4 (Non-character code points).
python.library.stringprep#stringprep.in_table_c4
stringprep.in_table_c5(code) Determine whether code is in tableC.5 (Surrogate codes).
python.library.stringprep#stringprep.in_table_c5
stringprep.in_table_c6(code) Determine whether code is in tableC.6 (Inappropriate for plain text).
python.library.stringprep#stringprep.in_table_c6
stringprep.in_table_c7(code) Determine whether code is in tableC.7 (Inappropriate for canonical representation).
python.library.stringprep#stringprep.in_table_c7
stringprep.in_table_c8(code) Determine whether code is in tableC.8 (Change display properties or are deprecated).
python.library.stringprep#stringprep.in_table_c8
stringprep.in_table_c9(code) Determine whether code is in tableC.9 (Tagging characters).
python.library.stringprep#stringprep.in_table_c9
stringprep.in_table_d1(code) Determine whether code is in tableD.1 (Characters with bidirectional property “R” or “AL”).
python.library.stringprep#stringprep.in_table_d1
stringprep.in_table_d2(code) Determine whether code is in tableD.2 (Characters with bidirectional property “L”).
python.library.stringprep#stringprep.in_table_d2
stringprep.map_table_b2(code) Return the mapped value for code according to tableB.2 (Mapping for case-folding used with NFKC).
python.library.stringprep#stringprep.map_table_b2
stringprep.map_table_b3(code) Return the mapped value for code according to tableB.3 (Mapping for case-folding used with no normalization).
python.library.stringprep#stringprep.map_table_b3
struct — Interpret bytes as packed binary data Source code: Lib/struct.py This module performs conversions between Python values and C structs represented as Python bytes objects. This can be used in handling binary data stored in files or from network connections, among other sources. It uses Format Strings as compact...
python.library.struct
struct.calcsize(format) Return the size of the struct (and hence of the bytes object produced by pack(format, ...)) corresponding to the format string format.
python.library.struct#struct.calcsize
exception struct.error Exception raised on various occasions; argument is a string describing what is wrong.
python.library.struct#struct.error
struct.iter_unpack(format, buffer) Iteratively unpack from the buffer buffer according to the format string format. This function returns an iterator which will read equally-sized chunks from the buffer until all its contents have been consumed. The buffer’s size in bytes must be a multiple of the size required by th...
python.library.struct#struct.iter_unpack
struct.pack(format, v1, v2, ...) Return a bytes object containing the values v1, v2, … packed according to the format string format. The arguments must match the values required by the format exactly.
python.library.struct#struct.pack
struct.pack_into(format, buffer, offset, v1, v2, ...) Pack the values v1, v2, … according to the format string format and write the packed bytes into the writable buffer buffer starting at position offset. Note that offset is a required argument.
python.library.struct#struct.pack_into
class struct.Struct(format) Return a new Struct object which writes and reads binary data according to the format string format. Creating a Struct object once and calling its methods is more efficient than calling the struct functions with the same format since the format string only needs to be compiled once. Note ...
python.library.struct#struct.Struct
format The format string used to construct this Struct object. Changed in version 3.7: The format string type is now str instead of bytes.
python.library.struct#struct.Struct.format
iter_unpack(buffer) Identical to the iter_unpack() function, using the compiled format. The buffer’s size in bytes must be a multiple of size. New in version 3.4.
python.library.struct#struct.Struct.iter_unpack
pack(v1, v2, ...) Identical to the pack() function, using the compiled format. (len(result) will equal size.)
python.library.struct#struct.Struct.pack
pack_into(buffer, offset, v1, v2, ...) Identical to the pack_into() function, using the compiled format.
python.library.struct#struct.Struct.pack_into
size The calculated size of the struct (and hence of the bytes object produced by the pack() method) corresponding to format.
python.library.struct#struct.Struct.size
unpack(buffer) Identical to the unpack() function, using the compiled format. The buffer’s size in bytes must equal size.
python.library.struct#struct.Struct.unpack
unpack_from(buffer, offset=0) Identical to the unpack_from() function, using the compiled format. The buffer’s size in bytes, starting at position offset, must be at least size.
python.library.struct#struct.Struct.unpack_from
struct.unpack(format, buffer) Unpack from the buffer buffer (presumably packed by pack(format, ...)) according to the format string format. The result is a tuple even if it contains exactly one item. The buffer’s size in bytes must match the size required by the format, as reflected by calcsize().
python.library.struct#struct.unpack
struct.unpack_from(format, /, buffer, offset=0) Unpack from buffer starting at position offset, according to the format string format. The result is a tuple even if it contains exactly one item. The buffer’s size in bytes, starting at position offset, must be at least the size required by the format, as reflected by ...
python.library.struct#struct.unpack_from
subprocess — Subprocess management Source code: Lib/subprocess.py The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several older modules and functions: os.system os.spawn* Information about how the subproce...
python.library.subprocess
subprocess.ABOVE_NORMAL_PRIORITY_CLASS A Popen creationflags parameter to specify that a new process will have an above average priority. New in version 3.7.
python.library.subprocess#subprocess.ABOVE_NORMAL_PRIORITY_CLASS
subprocess.BELOW_NORMAL_PRIORITY_CLASS A Popen creationflags parameter to specify that a new process will have a below average priority. New in version 3.7.
python.library.subprocess#subprocess.BELOW_NORMAL_PRIORITY_CLASS
subprocess.call(args, *, stdin=None, stdout=None, stderr=None, shell=False, cwd=None, timeout=None, **other_popen_kwargs) Run the command described by args. Wait for command to complete, then return the returncode attribute. Code needing to capture stdout or stderr should use run() instead: run(...).returncode To su...
python.library.subprocess#subprocess.call
exception subprocess.CalledProcessError Subclass of SubprocessError, raised when a process run by check_call() or check_output() returns a non-zero exit status. returncode Exit status of the child process. If the process exited due to a signal, this will be the negative signal number. cmd Command that was u...
python.library.subprocess#subprocess.CalledProcessError
cmd Command that was used to spawn the child process.
python.library.subprocess#subprocess.CalledProcessError.cmd
output Output of the child process if it was captured by run() or check_output(). Otherwise, None.
python.library.subprocess#subprocess.CalledProcessError.output
returncode Exit status of the child process. If the process exited due to a signal, this will be the negative signal number.
python.library.subprocess#subprocess.CalledProcessError.returncode
stderr Stderr output of the child process if it was captured by run(). Otherwise, None.
python.library.subprocess#subprocess.CalledProcessError.stderr
stdout Alias for output, for symmetry with stderr.
python.library.subprocess#subprocess.CalledProcessError.stdout
subprocess.check_call(args, *, stdin=None, stdout=None, stderr=None, shell=False, cwd=None, timeout=None, **other_popen_kwargs) Run command with arguments. Wait for command to complete. If the return code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code...
python.library.subprocess#subprocess.check_call
subprocess.check_output(args, *, stdin=None, stderr=None, shell=False, cwd=None, encoding=None, errors=None, universal_newlines=None, timeout=None, text=None, **other_popen_kwargs) Run command with arguments and return its output. If the return code was non-zero it raises a CalledProcessError. The CalledProcessError ...
python.library.subprocess#subprocess.check_output
class subprocess.CompletedProcess The return value from run(), representing a process that has finished. args The arguments used to launch the process. This may be a list or a string. returncode Exit status of the child process. Typically, an exit status of 0 indicates that it ran successfully. A negative v...
python.library.subprocess#subprocess.CompletedProcess
args The arguments used to launch the process. This may be a list or a string.
python.library.subprocess#subprocess.CompletedProcess.args
check_returncode() If returncode is non-zero, raise a CalledProcessError.
python.library.subprocess#subprocess.CompletedProcess.check_returncode
returncode Exit status of the child process. Typically, an exit status of 0 indicates that it ran successfully. A negative value -N indicates that the child was terminated by signal N (POSIX only).
python.library.subprocess#subprocess.CompletedProcess.returncode
stderr Captured stderr from the child process. A bytes sequence, or a string if run() was called with an encoding, errors, or text=True. None if stderr was not captured.
python.library.subprocess#subprocess.CompletedProcess.stderr
stdout Captured stdout from the child process. A bytes sequence, or a string if run() was called with an encoding, errors, or text=True. None if stdout was not captured. If you ran the process with stderr=subprocess.STDOUT, stdout and stderr will be combined in this attribute, and stderr will be None.
python.library.subprocess#subprocess.CompletedProcess.stdout
subprocess.CREATE_BREAKAWAY_FROM_JOB A Popen creationflags parameter to specify that a new process is not associated with the job. New in version 3.7.
python.library.subprocess#subprocess.CREATE_BREAKAWAY_FROM_JOB
subprocess.CREATE_DEFAULT_ERROR_MODE A Popen creationflags parameter to specify that a new process does not inherit the error mode of the calling process. Instead, the new process gets the default error mode. This feature is particularly useful for multithreaded shell applications that run with hard errors disabled. ...
python.library.subprocess#subprocess.CREATE_DEFAULT_ERROR_MODE
subprocess.CREATE_NEW_CONSOLE The new process has a new console, instead of inheriting its parent’s console (the default).
python.library.subprocess#subprocess.CREATE_NEW_CONSOLE
subprocess.CREATE_NEW_PROCESS_GROUP A Popen creationflags parameter to specify that a new process group will be created. This flag is necessary for using os.kill() on the subprocess. This flag is ignored if CREATE_NEW_CONSOLE is specified.
python.library.subprocess#subprocess.CREATE_NEW_PROCESS_GROUP
subprocess.CREATE_NO_WINDOW A Popen creationflags parameter to specify that a new process will not create a window. New in version 3.7.
python.library.subprocess#subprocess.CREATE_NO_WINDOW
subprocess.DETACHED_PROCESS A Popen creationflags parameter to specify that a new process will not inherit its parent’s console. This value cannot be used with CREATE_NEW_CONSOLE. New in version 3.7.
python.library.subprocess#subprocess.DETACHED_PROCESS
subprocess.DEVNULL Special value that can be used as the stdin, stdout or stderr argument to Popen and indicates that the special file os.devnull will be used. New in version 3.3.
python.library.subprocess#subprocess.DEVNULL
subprocess.getoutput(cmd) Return output (stdout and stderr) of executing cmd in a shell. Like getstatusoutput(), except the exit code is ignored and the return value is a string containing the command’s output. Example: >>> subprocess.getoutput('ls /bin/ls') '/bin/ls' Availability: POSIX & Windows. Changed in versi...
python.library.subprocess#subprocess.getoutput
subprocess.getstatusoutput(cmd) Return (exitcode, output) of executing cmd in a shell. Execute the string cmd in a shell with Popen.check_output() and return a 2-tuple (exitcode, output). The locale encoding is used; see the notes on Frequently Used Arguments for more details. A trailing newline is stripped from the ...
python.library.subprocess#subprocess.getstatusoutput
subprocess.HIGH_PRIORITY_CLASS A Popen creationflags parameter to specify that a new process will have a high priority. New in version 3.7.
python.library.subprocess#subprocess.HIGH_PRIORITY_CLASS
subprocess.IDLE_PRIORITY_CLASS A Popen creationflags parameter to specify that a new process will have an idle (lowest) priority. New in version 3.7.
python.library.subprocess#subprocess.IDLE_PRIORITY_CLASS
subprocess.NORMAL_PRIORITY_CLASS A Popen creationflags parameter to specify that a new process will have an normal priority. (default) New in version 3.7.
python.library.subprocess#subprocess.NORMAL_PRIORITY_CLASS
subprocess.PIPE Special value that can be used as the stdin, stdout or stderr argument to Popen and indicates that a pipe to the standard stream should be opened. Most useful with Popen.communicate().
python.library.subprocess#subprocess.PIPE
class subprocess.Popen(args, bufsize=-1, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=True, shell=False, cwd=None, env=None, universal_newlines=None, startupinfo=None, creationflags=0, restore_signals=True, start_new_session=False, pass_fds=(), *, group=None, extra_groups=None, user...
python.library.subprocess#subprocess.Popen
Popen.args The args argument as it was passed to Popen – a sequence of program arguments or else a single string. New in version 3.3.
python.library.subprocess#subprocess.Popen.args
Popen.communicate(input=None, timeout=None) Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate and set the returncode attribute. The optional input argument should be data to be sent to the child process, or None, if no data should ...
python.library.subprocess#subprocess.Popen.communicate