chunk_id
large_stringlengths
36
36
doc_type
large_stringclasses
2 values
category
large_stringclasses
17 values
document
large_stringclasses
50 values
version_raw
large_stringclasses
590 values
chunk_index
int64
0
262
text
large_stringlengths
11
5.69k
file_path
large_stringclasses
882 values
d4246ee9-020f-5c2f-9649-dabc4b58ed19
docs
python
python_stdtypes
314
54
also a [`list`](#list "list") (but not its subclasses). Operations that involve multiple accesses, as well as iteration, are never atomic. For example: ```None # NOT atomic: read-modify-write lst[i] = lst[i] + 1 # NOT atomic: check-then-act if lst: item = lst.pop() # NOT thread-safe: iteration while modifying f...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
79a1a212-e74d-55d3-9780-d120fb1d7d20
docs
python
python_stdtypes
314
55
[`dict`](#dict "dict") instance). *class* tuple(*iterable=()*, */*)[¶](#tuple "Link to this definition") : Tuples may be constructed in a number of ways: * Using a pair of parentheses to denote the empty tuple: `()` * Using a trailing comma for a singleton tuple: `a,` or `(a,)` * Separating items with c...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
447bbe91-7595-55f3-bfa9-d9d42ee9121a
docs
python
python_stdtypes
314
56
The parentheses are optional, except in the empty tuple case, or when they are needed to avoid syntactic ambiguity. For example, `f(a, b, c)` is a function call with three arguments, while `f((a, b, c))` is a function call with a 3-tuple as the sole argument. Tuples implement all of the [common](#t...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
6809f195-6e8a-5a40-900a-5de6867e9214
docs
python
python_stdtypes
314
57
: The arguments to the range constructor must be integers (either built-in [`int`](functions.html#int "int") or any object that implements the [`__index__()`](../reference/datamodel.html#object.__index__ "object.__index__") special method). If the *step* argument is omitted, it defaults to `1`. If the *st...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
aaa5e222-36df-583e-af0f-c3a22ab5b3a1
docs
python
python_stdtypes
314
58
Ranges containing absolute values larger than [`sys.maxsize`](sys.html#sys.maxsize "sys.maxsize") are permitted but some features (such as [`len()`](functions.html#len "len")) may raise [`OverflowError`](exceptions.html#OverflowError "OverflowError"). Range examples: ```None >>> list(range(10)...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
6122bece-680a-5ab2-a717-3609edbfb2e4
docs
python
python_stdtypes
314
59
: The value of the *start* parameter (or `0` if the parameter was not supplied) stop[¶](#range.stop "Link to this definition") : The value of the *stop* parameter step[¶](#range.step "Link to this definition") : The value of the *step* parameter (or `1` if the parameter was n...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1ab51f44-b030-54c8-8448-b1961a4f48da
docs
python
python_stdtypes
314
60
>>> r = range(0, 20, 2) >>> r range(0, 20, 2) >>> 11 in r False >>> 10 in r True >>> r.index(10) 5 >>> r[5] 10 >>> r[:5] range(0, 10, 2) >>> r[-1] 18 ``` Testing range objects for equality with `==` and `!=` compares them as sequences. That is, two range objects are considered equal if they represent the same sequence...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
f0b5622a-e5b5-5bb6-9321-0a271550cc18
docs
python
python_stdtypes
314
61
Added the [`start`](#range.start "range.start"), [`stop`](#range.stop "range.stop") and [`step`](#range.step "range.step") attributes. See also * The [linspace recipe](https://code.activestate.com/recipes/579000-equally-spaced-numbers-linspace/) shows how to implement a lazy version of range suitable for floating-p...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
642e2ec6-ed96-5479-b500-d4c582f7cb79
docs
python
python_stdtypes
314
62
| [printf-style String Formatting](#old-string-formatting) | | | | [printf-style Bytes Formatting](#bytes-formatting) | | | | | Searching and Replacing | [`str.find()`](#str.find "str.find") | [`str.rfind()`](#str.rfind "str.rfind") | | | [`bytes.find()`](#bytes.find "bytes.find") | [`bytes.rfind()`](#bytes.rfind "byte...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
346c17e6-390c-5949-b2aa-2440c694661b
docs
python
python_stdtypes
314
63
| Splitting and Joining | [`str.split()`](#str.split "str.split") | | [`str.rsplit()`](#str.rsplit "str.rsplit") | | [`bytes.split()`](#bytes.split "bytes.split") | | [`bytes.rsplit()`](#bytes.rsplit "bytes.rsplit") | | | [`str.splitlines()`](#str.splitlines "str.splitlines") | | | | [`bytes.splitlines()`](#bytes.split...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
7bae4035-4f87-57bd-be9a-5fc87948de13
docs
python
python_stdtypes
314
64
| [`str.isdigit()`](#str.isdigit "str.isdigit") | | | | [`bytes.isdigit()`](#bytes.isdigit "bytes.isdigit") | | | | | [`str.isnumeric()`](#str.isnumeric "str.isnumeric") | | | | | | | | | [`str.isalnum()`](#str.isalnum "str.isalnum") | | | | [`bytes.isalnum()`](#bytes.isalnum "bytes.isalnum") | | | | | [`str.isidentif...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
96fd17a0-5964-5641-8a5c-1c08c8615fa7
docs
python
python_stdtypes
314
65
| Case Manipulation | [`str.lower()`](#str.lower "str.lower") | | | | [`bytes.lower()`](#bytes.lower "bytes.lower") | | | | | [`str.upper()`](#str.upper "str.upper") | | | | [`bytes.upper()`](#bytes.upper "bytes.upper") | | | | | [`str.casefold()`](#str.casefold "str.casefold") | | | | | | | | | [`str.capitalize()`](#...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
c6858131-c101-57ca-8c24-a2aab34bf607
docs
python
python_stdtypes
314
66
| [`str.expandtabs()`](#str.expandtabs "str.expandtabs") | | | | [`bytes.expandtabs()`](#bytes.expandtabs "bytes.expandtabs") | | | | | [`str.strip()`](#str.strip "str.strip") | | | | [`bytes.strip()`](#bytes.strip "bytes.strip") | | | | | [`str.lstrip()`](#str.lstrip "str.lstrip") | | | [`str.rstrip()`](#str.rstrip "s...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
a85c6733-6f73-50f5-b1eb-d77c6d30419a
docs
python
python_stdtypes
314
67
## Text Sequence Type — [`str`](#str "str")[¶](#text-sequence-type-str "Link to this heading") Textual data in Python is handled with [`str`](#str "str") objects, or *strings*. Strings are immutable [sequences](#typesseq) of Unicode code points. String literals are written in a variety of ways: * Single quotes: `'all...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
fbdb6d5d-0455-5113-b425-4bf4ade1a9cf
docs
python
python_stdtypes
314
68
including supported [escape sequences](../reference/lexical_analysis.html#escape-sequences), and the `r` (“raw”) prefix that disables most escape sequence processing. Strings may also be created from other objects using the [`str`](#str "str") constructor. Since there is no separate “character” type, indexing a strin...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
aa31d7a2-b877-5b7a-9bf2-586777bc41c4
docs
python
python_stdtypes
314
69
*class* str(*object*, *\**, *errors*) : Return a [string](#textseq) version of *object*. If *object* is not provided, returns the empty string. Otherwise, the behavior of `str()` depends on whether *encoding* or *errors* is given, as follows. If neither *encoding* nor *errors* is given, `str(object)` ret...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
bec470a3-25e0-52e6-b260-38aafedef9cf
docs
python
python_stdtypes
314
70
this case, if *object* is a [`bytes`](#bytes "bytes") (or [`bytearray`](#bytearray "bytearray")) object, then `str(bytes, encoding, errors)` is equivalent to [`bytes.decode(encoding, errors)`](#bytes.decode "bytes.decode"). Otherwise, the bytes object underlying the buffer object is obtained before call...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
54a31980-7ea1-5334-928a-a5509dcb4871
docs
python
python_stdtypes
314
71
[Text Sequence Type — str](#textseq) and the [String Methods](#string-methods) section below. To output formatted strings, see the [f-strings](../reference/lexical_analysis.html#f-strings) and [Format String Syntax](string.html#formatstrings) sections. In addition, see the [Text Processing Services](text.ht...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
b708bd80-8ba4-53c0-95a4-ce5735cc63ca
docs
python
python_stdtypes
314
72
handle ([printf-style String Formatting](#old-string-formatting)). The [Text Processing Services](text.html#textservices) section of the standard library covers a number of other modules that provide various text related utilities (including regular expression support in the [`re`](re.html#module-re "re: Regular expre...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e200d08e-683b-5860-ab66-9a00722d5b7e
docs
python
python_stdtypes
314
73
intended to remove all case distinctions in a string. For example, the German lowercase letter `'ß'` is equivalent to `"ss"`. Since it is already lowercase, [`lower()`](#str.lower "str.lower") would do nothing to `'ß'`; [`casefold()`](#str.casefold "str.casefold") converts it to `"ss"`. For example:...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
af71ce5d-f033-5b33-abcc-7fbc532a27d7
docs
python
python_stdtypes
314
74
>>> 'Python'.center(10, '-') '--Python--' >>> 'Python'.center(4) 'Python' ``` str.count(*sub*[, *start*[, *end*]])[¶](#str.count "Link to this definition") : Return the number of non-overlapping occurrences of substring *sub* in the range [*start*, *end*]. Optional arguments *start* and *end*...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
fd14e3f0-07c7-50d6-b2b0-1a3cc1557e2f
docs
python
python_stdtypes
314
75
see [Standard Encodings](codecs.html#standard-encodings) for possible values. *errors* controls how encoding errors are handled. If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised. Other possible values are `'ignore'`, `'replace'`, `'xml...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
164d0761-e189-537a-b318-e500888fa811
docs
python
python_stdtypes
314
76
Changed in version 3.1: Added support for keyword arguments. Changed in version 3.9: The value of the *errors* argument is now checked in [Python Development Mode](devmode.html#devmode) and in [debug mode](../using/configure.html#debug-build). str.endswith(*suffix*[, *start*[, *end*]])[¶](#str.endswith "L...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
4bae917d-54ce-5016-8a1d-a5f48be0fea0
docs
python
python_stdtypes
314
77
See also [`startswith()`](#str.startswith "str.startswith") and [`removesuffix()`](#str.removesuffix "str.removesuffix"). str.expandtabs(*tabsize=8*)[¶](#str.expandtabs "Link to this definition") : Return a copy of the string where all tab characters are replaced by one or more spaces, depending on the curre...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
690d18cb-17fd-5288-a79e-a94d5be40e24
docs
python
python_stdtypes
314
78
incremented by one regardless of how the character is represented when printed. For example: ```None >>> '01\t012\t0123\t01234'.expandtabs() '01 012 0123 01234' >>> '01\t012\t0123\t01234'.expandtabs(4) '01 012 0123 01234' >>> print('01\t012\n0123\t01234'.expandtabs(4)) ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
9d41cdeb-bb9d-5350-b591-c42b508a90e6
docs
python
python_stdtypes
314
79
position of *sub*. To check if *sub* is a substring or not, use the [`in`](../reference/expressions.html#in) operator: ```None >>> 'Py' in 'Python' True ``` str.format(*\*args*, *\*\*kwargs*)[¶](#str.format "Link to this definition") : Perform a string formatting operation. The string on whi...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
b427538c-597b-5edd-8c66-27868d3b2eb8
docs
python
python_stdtypes
314
80
See [Format String Syntax](string.html#formatstrings) for a description of the various formatting options that can be specified in format strings. Note When formatting a number ([`int`](functions.html#int "int"), [`float`](functions.html#float "float"), [`complex`](functions.html#complex "complex"), ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
6853d4db-fcc7-55c0-a6e5-25fffd0cd1e6
docs
python
python_stdtypes
314
81
str.format\_map(*mapping*, */*)[¶](#str.format_map "Link to this definition") : Similar to `str.format(**mapping)`, except that `mapping` is used directly and not copied to a [`dict`](#dict "dict"). This is useful if for example `mapping` is a dict subclass: ```None >>> class Default(dict): ... ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
bbe194b5-7a12-57ed-9767-76049197839d
docs
python
python_stdtypes
314
82
~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^ ValueError: substring not found ``` See also [`rindex()`](#str.rindex "str.rindex"). str.isalnum()[¶](#str.isalnum "Link to this definition") : Return `True` if all characters in the string are alphanumeric and there is at least one character, `False` otherwi...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e040f549-9ed2-59a4-a031-45ebdd6feeec
docs
python
python_stdtypes
314
83
Ideographic’ of the Unicode Standard](https://www.unicode.org/versions/Unicode16.0.0/core-spec/chapter-4/#G91002). For example: ```None >>> 'Letters and spaces'.isalpha() False >>> 'LettersOnly'.isalpha() True >>> 'µ'.isalpha() # non-ASCII characters can be considered alphabetical too ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
c52eec97-8c4f-5a1d-8159-5a6aa7e8b3b9
docs
python
python_stdtypes
314
84
otherwise. Decimal characters are those that can be used to form numbers in base 10, such as U+0660, ARABIC-INDIC DIGIT ZERO. Formally a decimal character is a character in the Unicode General Category “Nd”. For example: ```None >>> '0123456789'.isdecimal() True >>> '٠١٢٣٤٥٦٧٨٩'.isdecim...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
200bf981-245f-535c-b359-9a34a30f706e
docs
python
python_stdtypes
314
85
: Return `True` if the string is a valid identifier according to the language definition, section [Names (identifiers and keywords)](../reference/lexical_analysis.html#identifiers). [`keyword.iskeyword()`](keyword.html#keyword.iskeyword "keyword.iskeyword") can be used to test whether string `s` is a reserve...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e7da1c03-97ae-5788-a510-303a7db754ce
docs
python
python_stdtypes
314
86
characters, and there is at least one character, `False` otherwise. Numeric characters include digit characters, and all characters that have the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION ONE FIFTH. Formally, numeric characters are those with the property value Numeric\_Type=Digit...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
b6c5310c-c10e-561c-9bd5-fa3585ea8b07
docs
python
python_stdtypes
314
87
contains at least one non-printable character. Here “printable” means the character is suitable for [`repr()`](functions.html#repr "repr") to use in its output; “non-printable” means that [`repr()`](functions.html#repr "repr") on built-in types will hex-escape the character. It has no bearing on the ha...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e3185b7b-8e31-5a80-a044-9f21b2d90d36
docs
python
python_stdtypes
314
88
(False, False) ``` str.isspace()[¶](#str.isspace "Link to this definition") : Return `True` if there are only whitespace characters in the string and there is at least one character, `False` otherwise. A character is *whitespace* if in the Unicode character database (see [`unicodedata`](unicoded...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
8114ddc1-9949-59e4-905c-46cdad851e75
docs
python
python_stdtypes
314
89
See also [`title()`](#str.title "str.title"). str.isupper()[¶](#str.isupper "Link to this definition") : Return `True` if all cased characters [[4]](#id15) in the string are uppercase and there is at least one cased character, `False` otherwise. ```None >>> 'BANANA'.isupper() True >>> 'banan...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
5805a750-a93d-58a2-b4ed-ba7e7279188c
docs
python
python_stdtypes
314
90
str.ljust(*width*, *fillchar=' '*, */*)[¶](#str.ljust "Link to this definition") : Return the string left justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`. For ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
6b8992ee-e7d8-5928-a391-f8a0e9dff2d3
docs
python
python_stdtypes
314
91
str.lstrip(*chars=None*, */*)[¶](#str.lstrip "Link to this definition") : Return a copy of the string with leading characters removed. The *chars* argument is a string specifying the set of characters to be removed. If omitted or `None`, the *chars* argument defaults to removing whitespace. The *chars* ar...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
3d50bfd5-9dd1-526c-9765-52d4d182d35d
docs
python
python_stdtypes
314
92
: This static method returns a translation table usable for [`str.translate()`](#str.translate "str.translate"). If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters (strings of length 1) to Unicode ordinals, strings (of arbitrary lengths) or `None`. Ch...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
be5e9224-a2bf-5b3d-b2e6-784a2261d23b
docs
python
python_stdtypes
314
93
the string itself, followed by two empty strings. str.removeprefix(*prefix*, */*)[¶](#str.removeprefix "Link to this definition") : If the string starts with the *prefix* string, return `string[len(prefix):]`. Otherwise, return a copy of the original string: ```None >>> 'TestHook'.removeprefix('...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
ef4a1d83-1ea7-53a6-af49-6f1a5be90e9b
docs
python
python_stdtypes
314
94
See also [`removeprefix()`](#str.removeprefix "str.removeprefix") and [`endswith()`](#str.endswith "str.endswith"). str.replace(*old*, *new*, */*, *count=-1*)[¶](#str.replace "Link to this definition") : Return a copy of the string with all occurrences of substring *old* replaced by *new*. If *count* is give...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
9c1442e2-03ef-5d57-800b-f116c078162c
docs
python
python_stdtypes
314
95
and *end* are interpreted as in slice notation. Return `-1` on failure. For example: ```None >>> 'spam, spam, spam'.rfind('sp') 12 >>> 'spam, spam, spam'.rfind('sp', 0, 10) 6 ``` See also [`find()`](#str.find "str.find") and [`rindex()`](#str.rindex "str.rindex"). str.rindex(*sub*...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1df4ff40-8172-5609-ab9b-16915b518cf4
docs
python
python_stdtypes
314
96
str.rjust(*width*, *fillchar=' '*, */*)[¶](#str.rjust "Link to this definition") : Return the string right justified in a string of length *width*. Padding is done using the specified *fillchar* (default is an ASCII space). The original string is returned if *width* is less than or equal to `len(s)`. str.rpa...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
54cca9db-ab9c-5f0e-bed7-c4cf94030d3b
docs
python
python_stdtypes
314
97
str.rsplit(*sep=None*, *maxsplit=-1*)[¶](#str.rsplit "Link to this definition") : Return a list of the words in the string, using *sep* as the delimiter string. If *maxsplit* is given, at most *maxsplit* splits are done, the *rightmost* ones. If *sep* is not specified or `None`, any whitespace string is a ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
45800dfa-5922-5265-b286-a60f55c37d30
docs
python
python_stdtypes
314
98
See [`str.removesuffix()`](#str.removesuffix "str.removesuffix") for a method that will remove a single suffix string rather than all of a set of characters. For example: ```None >>> 'Monty Python'.rstrip(' Python') 'M' >>> 'Monty Python'.removesuffix(' Python') 'Monty' ``` str.split(*...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1246c707-0d5b-531d-8301-212e77a05457
docs
python
python_stdtypes
314
99
[`re.split()`](re.html#re.split "re.split")). Splitting an empty string with a specified separator returns `['']`. For example: ```None >>> '1,2,3'.split(',') ['1', '2', '3'] >>> '1,2,3'.split(',', maxsplit=1) ['1', '2,3'] >>> '1,2,,3,'.split(',') ['1', '2', '', '3', ''] >>...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
96567fe5-c738-56f9-900b-164273e8c7c9
docs
python
python_stdtypes
314
100
If *sep* is not specified or is `None` and *maxsplit* is `0`, only leading runs of consecutive whitespace are considered. For example: ```None >>> "".split(None, 0) [] >>> " ".split(None, 0) [] >>> " foo ".split(maxsplit=0) ['foo '] ``` See also [`join()`](#str...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
73f5bbcf-ca3d-51d6-b10c-5b1985c02632
docs
python
python_stdtypes
314
101
| `\x1c` | File Separator | | `\x1d` | Group Separator | | `\x1e` | Record Separator | | `\x85` | Next Line (C1 Control Code) | | `\u2028` | Line Separator | | `\u2029` | Paragraph Separator | Changed in version 3.2: `\v` and `\f` added to list of line boundaries. For example: ```...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
01251be8-8bc4-529a-a1cc-765c6c69acac
docs
python
python_stdtypes
314
102
str.startswith(*prefix*[, *start*[, *end*]])[¶](#str.startswith "Link to this definition") : Return `True` if string starts with the *prefix*, otherwise return `False`. *prefix* can also be a tuple of prefixes to look for. With optional *start*, test string beginning at that position. With optional *end*, sto...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
b8e2dae4-15de-5ea3-8133-427bd52b4efb
docs
python
python_stdtypes
314
103
The *chars* argument is not a prefix or suffix; rather, all combinations of its values are stripped: ```None >>> ' spacious '.strip() 'spacious' >>> 'www.example.com'.strip('cmowz.') 'example' ``` The outermost leading and trailing *chars* argument values are stripped from ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
26291448-7ece-5157-8d63-5bd773ea6209
docs
python
python_stdtypes
314
104
: Return a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase. For example: ```None >>> 'Hello world'.title() 'Hello World' ``` The algorithm uses a simple language-independent definition of a word as groups of c...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
9b0517ee-f81a-52fa-bde0-b2d89184d3c1
docs
python
python_stdtypes
314
105
... lambda mo: mo.group(0).capitalize(), ... s) ... >>> titlecase("they're bill's friends.") "They're Bill's Friends." ``` See also [`istitle()`](#str.istitle "str.istitle"). str.translate(*table*, */*)[¶](#str.translate "Link to this definition") : Re...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
eeeacdfb-b2b2-5a6a-85f9-6cffdebce539
docs
python
python_stdtypes
314
106
[`LookupError`](exceptions.html#LookupError "LookupError") exception, to map the character to itself. You can use [`str.maketrans()`](#str.maketrans "str.maketrans") to create a translation map from character-to-character mappings in different formats. See also the [`codecs`](codecs.html#module-codecs...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1d82211d-f0c7-53ff-86fa-5b05ad78e3ac
docs
python
python_stdtypes
314
107
str.zfill(*width*, */*)[¶](#str.zfill "Link to this definition") : 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 ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e3b1a283-0a7e-5f2c-b87e-25347a7280cc
docs
python
python_stdtypes
314
108
An *f-string* (formally a *formatted string literal*) is a string literal that is prefixed with `f` or `F`. This type of string literal allows embedding the results of arbitrary Python expressions within *replacement fields*, which are delimited by curly brackets (`{}`). Each replacement field must contain an expressi...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
8a84a6b0-cc2c-5c89-ace1-4fafe657e190
docs
python
python_stdtypes
314
109
'number=14.3' ``` Whitespace before, inside and after the expression, as well as whitespace after the equal sign, is significant — it is retained in the result: ```None >>> f'{ number - 4 = }' ' number - 4 = 10.3' ``` #### Conversion specifier[¶](#conversion-specifier "Link to this heading") By default, the v...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
8f1cd793-04d6-5963-a2b8-8e34ecc463e2
docs
python
python_stdtypes
314
110
>>> f'{one_third!s} is {one_third!r}' '1/3 is Fraction(1, 3)' >>> string = "¡kočka 😸!" >>> ascii(string) "'\\xa1ko\\u010dka \\U0001f638!'" >>> f'{string = !a}' "string = '\\xa1ko\\u010dka \\U0001f638!'" ``` #### Format specifier[¶](#format-specifier "Link to this heading") After the expression has been evaluated, ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
a9804fd6-8b79-5ab6-99cc-a08aceab3fe2
docs
python
python_stdtypes
314
111
### Template String Literals (t-strings)[¶](#template-string-literals-t-strings "Link to this heading") An *t-string* (formally a *template string literal*) is a string literal that is prefixed with `t` or `T`. These strings follow the same syntax and evaluation rules as [formatted string literals](#stdtypes-fstrings...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
07c1b480-b3ee-5514-8942-ba0bf66c1347
docs
python
python_stdtypes
314
112
It is up to code that processes the resulting [`Template`](string.templatelib.html#string.templatelib.Template "string.templatelib.Template") object to decide how to handle format specifiers and conversions. * Format specifiers containing nested replacement fields are evaluated eagerly, prior to being passed to t...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
356a3ce7-cb89-57de-b75e-7eb485bc4075
docs
python
python_stdtypes
314
113
normal, except that [`conversion`](string.templatelib.html#string.templatelib.Interpolation.conversion "string.templatelib.Interpolation.conversion") will be set to ‘`r`’ ([`repr()`](functions.html#repr "repr")) by default. If an explicit conversion or format specifier are provided, this will override the defau...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
41a3ae4f-23ce-53dd-82fa-a0a8eaf592f7
docs
python
python_stdtypes
314
114
String objects have one unique built-in operation: the `%` operator (modulo). This is also known as the string *formatting* or *interpolation* operator. Given `format % values` (where *format* is a string), `%` conversion specifications in *format* are replaced with zero or more elements of *values*. The effect is simi...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
efaf7ea7-62d1-508e-9d1f-8012eb542a5e
docs
python
python_stdtypes
314
115
(for example, `(somename)`). 3. Conversion flags (optional), which affect the result of some conversion types. 4. Minimum field width (optional). If specified as an `'*'` (asterisk), the actual width is read from the next element of the tuple in *values*, and the object to convert comes after the minimum fi...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
45eee447-176e-50f0-992f-1c8afcb2de5b
docs
python
python_stdtypes
314
116
... {'language': "Python", "number": 2}) Python has 002 quote types. ``` In this case no `*` specifiers may occur in a format (since they require a sequential parameter list). The conversion flag characters are: | Flag | Meaning | | --- | --- | | `'#'` | The value conversion will use the “alternate form” (wher...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
b060d9ef-ee82-5132-8b81-03b97f8ca1f2
docs
python
python_stdtypes
314
117
| `'i'` | Signed integer decimal. | | | `'o'` | Signed octal value. | (1) | | `'u'` | Obsolete type – it is identical to `'d'`. | (6) | | `'x'` | Signed hexadecimal (lowercase). | (2) | | `'X'` | Signed hexadecimal (uppercase). | (2) | | `'e'` | Floating-point exponential format (lowercase). | (3) | | `'E'` | Floating...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
aeba60f7-c269-5c2e-b23b-ab5802cb9e14
docs
python
python_stdtypes
314
118
| `'s'` | String (converts any Python object using [`str()`](#str "str")). | (5) | | `'a'` | String (converts any Python object using [`ascii()`](functions.html#ascii "ascii")). | (5) | | `'%'` | No argument is converted, results in a `'%'` character in the result. | | Notes: 1. The alternate form causes a leading o...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
44e5d8e4-94fc-5d20-9ea7-1861c95f87bb
docs
python
python_stdtypes
314
119
5. If precision is `N`, the output is truncated to `N` characters. 6. See [**PEP 237**](https://peps.python.org/pep-0237/). Since Python strings have an explicit length, `%s` conversions do not assume that `'\0'` is the end of the string. Changed in version 3.1: `%f` conversions for numbers whose absolute value is ov...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e5997271-50a2-5905-b4de-6f7bcc2b6edd
docs
python
python_stdtypes
314
120
The [`array`](array.html#module-array "array: Space efficient arrays of uniformly typed numeric values.") module supports efficient storage of basic data types like 32-bit integers and IEEE754 double-precision floating values. ### Bytes Objects[¶](#bytes-objects "Link to this heading") Bytes objects are immutable seq...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
3b680968-bf46-5856-9552-9570b68cb286
docs
python
python_stdtypes
314
121
* Triple quoted: `b'''3 single quotes'''`, `b"""3 double quotes"""` Only ASCII characters are permitted in bytes literals (regardless of the declared source code encoding). Any binary values over 127 must be entered into bytes literals using the appropriate escape sequence. As with string literals...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
6f7fa8d9-f1b7-5d10-aa48-0d850d0e6951
docs
python
python_stdtypes
314
122
elements and can be usefully manipulated with some text-oriented algorithms, this is not generally the case for arbitrary binary data (blindly applying text processing algorithms to binary data formats that are not ASCII compatible will usually lead to data corruption). In addition to the literal f...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
400ef929-18f8-519c-b388-b3c962252f38
docs
python
python_stdtypes
314
123
: This [`bytes`](#bytes "bytes") class method returns a bytes object, decoding the given string object. The string must contain two hexadecimal digits per byte, with ASCII whitespace being ignored. ```None >>> bytes.fromhex('2Ef0 F1f2 ') b'.\xf0\xf1\xf2' ``` ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
966e98f0-17e9-5243-a954-452fa21ef2b0
docs
python
python_stdtypes
314
124
```None >>> b'\xf0\xf1\xf2'.hex() 'f0f1f2' ``` If you want to make the hex string easier to read, you can specify a single character separator *sep* parameter to include in the output. By default, this separator will be included between each byte. A secon...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
004a6f6a-1a5f-5ca6-a23f-33060d32244f
docs
python
python_stdtypes
314
125
Since bytes objects are sequences of integers (akin to a tuple), for a bytes object *b*, `b[0]` will be an integer, while `b[0:1]` will be a bytes object of length 1. (This contrasts with text strings, where both indexing and slicing will produce a string of length 1) The representation of bytes objects uses the liter...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
15714e77-fcb3-53cc-8f6b-a98ca0db2c91
docs
python
python_stdtypes
314
126
* Creating a zero-filled instance with a given length: `bytearray(10)` * From an iterable of integers: `bytearray(range(20))` * Copying existing binary data via the buffer protocol: `bytearray(b'Hi!')` As bytearray objects are mutable, they support the [mutable](#typesseq-mutable) sequence operatio...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1eef0af6-9f1b-5c86-9f0f-4a1487ade776
docs
python
python_stdtypes
314
127
the given string object. The string must contain two hexadecimal digits per byte, with ASCII whitespace being ignored. ```None >>> bytearray.fromhex('2Ef0 F1f2 ') bytearray(b'.\xf0\xf1\xf2') ``` Changed in version 3.7: [`bytearray.fromhex()`](#bytearray.fromhex...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
c50f728c-c0e7-5565-8f3d-2812bafbd267
docs
python
python_stdtypes
314
128
>>> bytearray(b'\xf0\xf1\xf2').hex() 'f0f1f2' ``` Added in version 3.5. Changed in version 3.8: Similar to [`bytes.hex()`](#bytes.hex "bytes.hex"), [`bytearray.hex()`](#bytearray.hex "bytearray.hex") now supports optional *sep* and *bytes\_per\_sep* parameters to insert...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
7610495c-8cef-556d-a05d-88367fe782ca
docs
python
python_stdtypes
314
129
... ba += b'\0' * (size - len(ba)) ``` Examples: ```None >>> shrink = bytearray(b'abc') >>> shrink.resize(1) >>> (shrink, len(shrink)) (bytearray(b'a'), 1) >>> grow = bytearray(b'abc') >>> grow.resize(5) >>> (grow, len(gro...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
e7438d47-cb26-5df4-8c5a-17e49053996d
docs
python
python_stdtypes
314
130
### Bytes and Bytearray Operations[¶](#bytes-and-bytearray-operations "Link to this heading") Both bytes and bytearray objects support the [common](#typesseq-common) sequence operations. They interoperate not just with operands of the same type, but with any [bytes-like object](../glossary.html#term-bytes-like-object)...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
a1ab0b87-0671-5164-b506-6504da80d3a1
docs
python
python_stdtypes
314
131
Using these ASCII based operations to manipulate binary data that is not stored in an ASCII based format may lead to data corruption. The following methods on bytes and bytearray objects can be used with arbitrary binary data. bytes.count(*sub*[, *start*[, *end*]])[¶](#bytes.count "Link to this definition") bytearra...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
cd751993-1b29-512a-851f-0b5a895b85e1
docs
python
python_stdtypes
314
132
bytes.removeprefix(*prefix*, */*)[¶](#bytes.removeprefix "Link to this definition") bytearray.removeprefix(*prefix*, */*)[¶](#bytearray.removeprefix "Link to this definition") : If the binary data starts with the *prefix* string, return `bytes[len(prefix):]`. Otherwise, return a copy of the original binary d...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
d428131e-c80a-5011-a56a-4afd22a196b2
docs
python
python_stdtypes
314
133
not empty, return `bytes[:-len(suffix)]`. Otherwise, return a copy of the original binary data: ```None >>> b'MiscTests'.removesuffix(b'Tests') b'Misc' >>> b'TmpDirMixin'.removesuffix(b'Tests') b'TmpDirMixin' ``` The *suffix* may be any [bytes-like object](../glossary.html#term-byt...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
7b63da98-ee23-5c22-96a3-26d1c9ba5dcf
docs
python
python_stdtypes
314
134
If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised. Other possible values are `'ignore'`, `'replace'`, and any other name registered via [`codecs.register_error()`](codecs.html#codecs.register_error "codecs.register_error"). See [Error Handle...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
0c18b611-a5ab-5f82-8145-5f542cf5a1ff
docs
python
python_stdtypes
314
135
Changed in version 3.9: The value of the *errors* argument is now checked in [Python Development Mode](devmode.html#devmode) and in [debug mode](../using/configure.html#debug-build). bytes.endswith(*suffix*[, *start*[, *end*]])[¶](#bytes.endswith "Link to this definition") bytearray.endswith(*suffix*[, *start...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1673b3df-c3cf-5c13-8c4b-10a2db29a9bc
docs
python
python_stdtypes
314
136
such that *sub* is contained in the slice `s[start:end]`. Optional arguments *start* and *end* are interpreted as in slice notation. Return `-1` if *sub* is not found. The subsequence to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object) or an integer in the range 0 ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
af892b60-cdd8-534e-9157-5cf22fd4b328
docs
python
python_stdtypes
314
137
subsequence is not found. The subsequence to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object) or an integer in the range 0 to 255. Changed in version 3.3: Also accept an integer in the range 0 to 255 as the subsequence. bytes.join(*iterable*, */*)[¶](#bytes.join "Lin...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
a9278f86-c200-52d3-999b-673390d27aa3
docs
python
python_stdtypes
314
138
*static* bytearray.maketrans(*from*, *to*, */*)[¶](#bytearray.maketrans "Link to this definition") : This static method returns a translation table usable for [`bytes.translate()`](#bytes.translate "bytes.translate") that will map each character in *from* into the character at the same position in *to*; *from...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
aa8becc7-3bb7-5bda-a504-fa8623067c5d
docs
python
python_stdtypes
314
139
The separator to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object). bytes.replace(*old*, *new*, *count=-1*, */*)[¶](#bytes.replace "Link to this definition") bytearray.replace(*old*, *new*, *count=-1*, */*)[¶](#bytearray.replace "Link to this definition") : Return a copy of the ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
c445cba0-6d98-5374-929d-29e3788a90e7
docs
python
python_stdtypes
314
140
found, such that *sub* is contained within `s[start:end]`. Optional arguments *start* and *end* are interpreted as in slice notation. Return `-1` on failure. The subsequence to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object) or an integer in the range 0 to 255. ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
5d40ada0-9112-5e2f-b96e-d9c2032d512b
docs
python
python_stdtypes
314
141
bytes.rpartition(*sep*, */*)[¶](#bytes.rpartition "Link to this definition") bytearray.rpartition(*sep*, */*)[¶](#bytearray.rpartition "Link to this definition") : Split the sequence at the last occurrence of *sep*, and return a 3-tuple containing the part before the separator, the separator itself or its by...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
62d6b8bc-092e-5daf-b51b-a00aeee2da1f
docs
python
python_stdtypes
314
142
look for. With optional *start*, test beginning at that position. With optional *end*, stop comparing at that position. The prefix(es) to search for may be any [bytes-like object](../glossary.html#term-bytes-like-object). bytes.translate(*table*, */*, *delete=b''*)[¶](#bytes.translate "Link to this defini...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
545f6ef3-590c-5e45-a92f-cc201a3cc6b7
docs
python
python_stdtypes
314
143
Changed in version 3.6: *delete* is now supported as a keyword argument. The following methods on bytes and bytearray objects have default behaviours that assume the use of ASCII compatible binary formats, but can still be used with arbitrary binary data by passing appropriate arguments. Note that all of the bytea...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
f9c8ba21-5155-51cf-8151-4d6789b17993
docs
python
python_stdtypes
314
144
bytes.ljust(*width*, *fillbyte=b' '*, */*)[¶](#bytes.ljust "Link to this definition") bytearray.ljust(*width*, *fillbyte=b' '*, */*)[¶](#bytearray.ljust "Link to this definition") : Return a copy of the object left justified in a sequence of length *width*. Padding is done using the specified *fillbyte* (defaul...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
3bf7fba8-583c-5a05-b98b-b96ce9ca87c2
docs
python
python_stdtypes
314
145
to removing ASCII whitespace. The *bytes* argument is not a prefix; rather, all combinations of its values are stripped: ```None >>> b' spacious '.lstrip() b'spacious ' >>> b'www.example.com'.lstrip(b'cmowz.') b'example.com' ``` The binary sequence of byte values to remove ma...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
3337ed0b-5f25-5b56-8f9d-ce40874d3cb2
docs
python
python_stdtypes
314
146
bytearray.rjust(*width*, *fillbyte=b' '*, */*)[¶](#bytearray.rjust "Link to this definition") : Return a copy of the object right justified in a sequence of length *width*. Padding is done using the specified *fillbyte* (default is an ASCII space). For [`bytes`](#bytes "bytes") objects, the original sequence ...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
cb3ee93b-a428-5345-9b1b-0ea0337a8b8f
docs
python
python_stdtypes
314
147
Except for splitting from the right, [`rsplit()`](#bytearray.rsplit "bytearray.rsplit") behaves like [`split()`](#bytearray.split "bytearray.split") which is described in detail below. bytes.rstrip(*bytes=None*, */*)[¶](#bytes.rstrip "Link to this definition") bytearray.rstrip(*bytes=None*, */*)[¶](#bytearray...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
13c6eb6f-87e4-5fc4-80cd-c8b42ec1994e
docs
python
python_stdtypes
314
148
[bytes-like object](../glossary.html#term-bytes-like-object). See [`removesuffix()`](#bytes.removesuffix "bytes.removesuffix") for a method that will remove a single suffix string rather than all of a set of characters. For example: ```None >>> b'Monty Python'.rstrip(b' Python') b'M' >>> b'...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
4248a042-ca1b-5800-a5fb-d966cf401e7e
docs
python
python_stdtypes
314
149
limit on the number of splits (all possible splits are made). If *sep* is given, consecutive delimiters are not grouped together and are deemed to delimit empty subsequences (for example, `b'1,,2'.split(b',')` returns `[b'1', b'', b'2']`). The *sep* argument may consist of a multibyte sequence as a...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
bb68aa7b-f376-5239-afd2-2d9ed82dd205
docs
python
python_stdtypes
314
150
separator, and the result will contain no empty strings at the start or end if the sequence has leading or trailing whitespace. Consequently, splitting an empty sequence or a sequence consisting solely of ASCII whitespace without a specified separator returns `[]`. For example: ```None >>>...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
a4861142-3f4e-5870-97c4-298e3345bda3
docs
python
python_stdtypes
314
151
```None >>> b' spacious '.strip() b'spacious' >>> b'www.example.com'.strip(b'cmowz.') b'example' ``` The binary sequence of byte values to remove may be any [bytes-like object](../glossary.html#term-bytes-like-object). Note The bytearray version of this method does *not* o...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
8ca93dbf-87c4-5f80-84e1-69c2549f9ac1
docs
python
python_stdtypes
314
152
Note The bytearray version of this method does *not* operate in place - it always produces a new object, even if no changes were made. bytes.expandtabs(*tabsize=8*)[¶](#bytes.expandtabs "Link to this definition") bytearray.expandtabs(*tabsize=8*)[¶](#bytearray.expandtabs "Link to this definition") : Re...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md
1ea4c572-3eff-554e-91e8-6d296e8f993d
docs
python
python_stdtypes
314
153
carriage return (`b'\r'`), it is copied and the current column is reset to zero. Any other byte value is copied unchanged and the current column is incremented by one regardless of how the byte value is represented when printed: ```None >>> b'01\t012\t0123\t01234'.expandtabs() b'01 012...
large_dataset/raw/docs/python/stdtypes/stdtypes_314.md