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 |
|---|---|---|---|---|---|---|---|
10f1ff93-4967-515a-82d7-a66a028b3c04 | docs | python | python_stdtypes | 315 | 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_315.md |
1c4775eb-dc93-5c9e-b506-618d6ffc16f3 | docs | python | python_stdtypes | 315 | 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_315.md |
4b60d42b-59f2-5106-91b9-cd8354c9bb8f | docs | python | python_stdtypes | 315 | 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_315.md |
872d3855-6ebd-5aff-920b-f8506c6a6223 | docs | python | python_stdtypes | 315 | 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_315.md |
64dbe5c7-7988-586e-9d0d-75998ba338b3 | docs | python | python_stdtypes | 315 | 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_315.md |
03cefb98-9777-53cf-975c-943a65805273 | docs | python | python_stdtypes | 315 | 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_315.md |
029f9dfc-35c7-5af7-9bd6-c07ee468f34c | docs | python | python_stdtypes | 315 | 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_315.md |
3746c06e-2708-5f51-bd1f-8466dee967b2 | docs | python | python_stdtypes | 315 | 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_315.md |
c188767d-7c47-5138-98f6-46afec810435 | docs | python | python_stdtypes | 315 | 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_315.md |
28884a91-2108-5751-913b-39e4ebb9182d | docs | python | python_stdtypes | 315 | 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_315.md |
a0410bf9-272b-5147-a81f-a88e3e254e86 | docs | python | python_stdtypes | 315 | 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_315.md |
7c18b549-25b2-5871-83a1-032e4fb4dff8 | docs | python | python_stdtypes | 315 | 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_315.md |
a1c34d94-beea-52a8-9a11-b7f47537e940 | docs | python | python_stdtypes | 315 | 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_315.md |
996f855e-4300-559d-adf8-9d06d4928a98 | docs | python | python_stdtypes | 315 | 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_315.md |
26d668d1-0c80-54cf-9fea-5ad2cc132508 | docs | python | python_stdtypes | 315 | 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_315.md |
08ad7bea-6fa1-5dab-8628-45c6529c4fb6 | docs | python | python_stdtypes | 315 | 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_315.md |
704c51d2-41b1-502a-bee1-4be9d898fd84 | docs | python | python_stdtypes | 315 | 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_315.md |
e77f8a67-8962-5de7-82ea-206fbcfb9cb6 | docs | python | python_stdtypes | 315 | 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_315.md |
481fefff-d3d4-5469-bee0-9cd0bbd8b002 | docs | python | python_stdtypes | 315 | 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_315.md |
0250a9f5-8c41-5add-b742-09bf2ed63902 | docs | python | python_stdtypes | 315 | 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_315.md |
1018a7e7-7bc8-59c6-9891-2cb3f739fcb2 | docs | python | python_stdtypes | 315 | 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_315.md |
51ab0a86-be8f-5faf-83a6-9c46c2e4c6a5 | docs | python | python_stdtypes | 315 | 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_315.md |
2512e64b-4a62-5347-ae6b-2f426fb3ef1d | docs | python | python_stdtypes | 315 | 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_315.md |
5a0753fb-6344-57f6-9c62-058f7e4e76cf | docs | python | python_stdtypes | 315 | 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_315.md |
9bd05f80-3516-50d0-90f6-78ee1ef12d3d | docs | python | python_stdtypes | 315 | 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_315.md |
85b20e86-95a1-5d11-84d4-909ff898ec40 | docs | python | python_stdtypes | 315 | 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_315.md |
4368e5af-37f8-5bf0-9c6f-581c7a038f31 | docs | python | python_stdtypes | 315 | 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_315.md |
84c560d1-a51c-57d6-9314-3329ea14daf9 | docs | python | python_stdtypes | 315 | 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_315.md |
9d1b1f3f-1f2e-54fe-9c7c-2170637ebcfc | docs | python | python_stdtypes | 315 | 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_315.md |
9821730c-4bb3-5239-899d-08f15b2438c1 | docs | python | python_stdtypes | 315 | 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_315.md |
74350bc3-9023-57a0-aa03-e1f29bcf440c | docs | python | python_stdtypes | 315 | 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_315.md |
d4a0d87c-9ebf-552e-b78e-f82580c53779 | docs | python | python_stdtypes | 315 | 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_315.md |
84285e71-dff7-5d2a-9409-20d0f53b0e9c | docs | python | python_stdtypes | 315 | 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_315.md |
2310dfbb-7b06-538a-bb2c-280917f9d608 | docs | python | python_stdtypes | 315 | 130 | [`bytearray`](#bytearray "bytearray"), which requires a copy. If the remaining bytes should be
discarded, use [`resize()`](#bytearray.resize "bytearray.resize") or [`del`](../reference/simple_stmts.html#del) to truncate
then [`take_bytes()`](#bytearray.take_bytes "bytearray.take_bytes") without ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
ad0dfb49-8738-5b92-8a30-8655c2d4c89a | docs | python | python_stdtypes | 315 | 131 | (`bytearray(b'...')`) since it is often more useful than e.g.
`bytearray([46, 46, 46])`. You can always convert a bytearray object into
a list of integers using `list(b)`.
### Bytes and Bytearray Operations[¶](#bytes-and-bytearray-operations "Link to this heading")
Both bytes and bytearray objects support the [common... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
5c40fbcd-7365-5b4f-9ecb-39e2da8e832d | docs | python | python_stdtypes | 315 | 132 | Some bytes and bytearray operations assume the use of ASCII compatible
binary formats, and hence should be avoided when working with arbitrary
binary data. These restrictions are covered below.
Note
Using these ASCII based operations to manipulate binary data that is not
stored in an ASCII based format may lead to da... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
71891ffb-1cb4-5d39-b5e3-3ba7b8584797 | docs | python | python_stdtypes | 315 | 133 | which is the length of the bytes object plus one.
Changed in version 3.3: Also accept an integer in the range 0 to 255 as the subsequence.
bytes.removeprefix(*prefix*, */*)[¶](#bytes.removeprefix "Link to this definition")
bytearray.removeprefix(*prefix*, */*)[¶](#bytearray.removeprefix "Link to this definit... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
9fe5c296-720e-5aa9-826a-2b8504ad3c74 | docs | python | python_stdtypes | 315 | 134 | bytearray.removesuffix(*suffix*, */*)[¶](#bytearray.removesuffix "Link to this definition")
: If the binary data ends with the *suffix* string and that *suffix* is
not empty, return `bytes[:-len(suffix)]`. Otherwise, return a copy of
the original binary data:
```None
>>> b'MiscTests'.removesuffix(b'T... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
738f5bc6-c039-54c1-9c1e-e25dc54f1bda | docs | python | python_stdtypes | 315 | 135 | see [Standard Encodings](codecs.html#standard-encodings) for possible values.
*errors* controls how decoding errors are handled.
If `'strict'` (the default), a [`UnicodeError`](exceptions.html#UnicodeError "UnicodeError") exception is raised.
Other possible values are `'ignore'`, `'replace'`,
and a... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
38b7f9ad-63cd-52f8-b8b7-17c1da0b81c9 | docs | python | python_stdtypes | 315 | 136 | 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).
bytes.endswith(*suffix*[, *start*[, *end*]])[¶](#bytes.endswit... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
7ec9d56f-15d1-5e0a-baa1-cfa056c6f03e | docs | python | python_stdtypes | 315 | 137 | : Return the lowest index in the data where the subsequence *sub* is found,
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 obje... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
f948d1b3-b9ff-5c64-b9d3-dcff4daa6b12 | docs | python | python_stdtypes | 315 | 138 | : Like [`find()`](#bytes.find "bytes.find"), but raise [`ValueError`](exceptions.html#ValueError "ValueError") when the
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 vers... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
38ffde9c-03e4-576c-9765-25ed39ea50f9 | docs | python | python_stdtypes | 315 | 139 | *static* bytes.maketrans(*from*, *to*, */*)[¶](#bytes.maketrans "Link to this definition")
*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 ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
a650257c-465a-5555-b94a-fec1507d9842 | docs | python | python_stdtypes | 315 | 140 | containing a copy of the original sequence, followed by two empty bytes or
bytearray objects.
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(*o... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
44048f55-a9ff-5b65-9f0a-707df1e842e2 | docs | python | python_stdtypes | 315 | 141 | bytearray.rfind(*sub*[, *start*[, *end*]])[¶](#bytearray.rfind "Link to this definition")
: Return the highest index in the sequence where the subsequence *sub* is
found, such that *sub* is contained within `s[start:end]`. Optional
arguments *start* and *end* are interpreted as in slice notation. Return
`... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
5cea5213-896f-5655-b2df-d6fb2e68a231 | docs | python | python_stdtypes | 315 | 142 | 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.rpartition(*sep*, */*)[¶](#bytes.rpartition "Link to this definition")
... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
c9df8f86-3a4d-51e2-b927-f78b4bb31026 | docs | python | python_stdtypes | 315 | 143 | bytearray.startswith(*prefix*[, *start*[, *end*]])[¶](#bytearray.startswith "Link to this definition")
: Return `True` if the binary data starts with the specified *prefix*,
otherwise return `False`. *prefix* can also be a tuple of prefixes to
look for. With optional *start*, test beginning at that position. ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
66e14d8f-f07b-5ec1-855e-7595f9c5ccc2 | docs | python | python_stdtypes | 315 | 144 | You can use the [`bytes.maketrans()`](#bytes.maketrans "bytes.maketrans") method to create a translation
table.
Set the *table* argument to `None` for translations that only delete
characters:
```None
>>> b'read this short text'.translate(None, b'aeiou')
b'rd ths shrt txt'
```
Cha... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
31414cd3-a6f1-5c59-9aba-46cea095f96d | docs | python | python_stdtypes | 315 | 145 | Padding is done using the specified *fillbyte* (default is an ASCII
space). For [`bytes`](#bytes "bytes") objects, the original sequence is returned if
*width* is less than or equal to `len(s)`.
Note
The bytearray version of this method does *not* operate in place -
it always produces a new ob... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
2512514a-6a96-5c22-86b0-8e821177f395 | docs | python | python_stdtypes | 315 | 146 | bytes.lstrip(*bytes=None*, */*)[¶](#bytes.lstrip "Link to this definition")
bytearray.lstrip(*bytes=None*, */*)[¶](#bytearray.lstrip "Link to this definition")
: Return a copy of the sequence with specified leading bytes removed. The
*bytes* argument is a binary sequence specifying the set of byte values to
... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
23b6b08e-ca3f-5e82-aab3-ad103fb42003 | docs | python | python_stdtypes | 315 | 147 | b'ee!'
>>> b'Arthur: three!'.removeprefix(b'Arthur: ')
b'three!'
```
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.rjust(*width*, *fillbyte=b' '*, */*)[¶](#bytes.rjust "Link to this definition")... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
6a6149c9-29e0-5239-9d58-7181138ef405 | docs | python | python_stdtypes | 315 | 148 | bytearray.rsplit(*sep=None*, *maxsplit=-1*)[¶](#bytearray.rsplit "Link to this definition")
: Split the binary sequence into subsequences of the same type, 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`... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
03f1fb56-af75-5fc3-8268-6eff14d4ac53 | docs | python | python_stdtypes | 315 | 149 | removing ASCII whitespace. The *bytes* argument is not a suffix; rather,
all combinations of its values are stripped:
```None
>>> b' spacious '.rstrip()
b' spacious'
>>> b'mississippi'.rstrip(b'ipz')
b'mississ'
```
The binary sequence of byte values to remove may be any
[... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
f5edaab0-eefb-5a1b-ab45-172058b23cfe | docs | python | python_stdtypes | 315 | 150 | : Split the binary sequence into subsequences of the same type, using *sep*
as the delimiter string. If *maxsplit* is given and non-negative, at most
*maxsplit* splits are done (thus, the list will have at most `maxsplit+1`
elements). If *maxsplit* is not specified or is `-1`, then there is no
limit o... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
fad5c716-00b5-55c3-af55-c2e879b90a18 | docs | python | python_stdtypes | 315 | 151 | [b'1', b'2,3']
>>> b'1,2,,3,'.split(b',')
[b'1', b'2', b'', b'3', b'']
>>> b'1<>2<>3<4'.split(b'<>')
[b'1', b'2', b'3<4']
```
If *sep* is not specified or is `None`, a different splitting algorithm
is applied: runs of consecutive ASCII whitespace are regarded as a single
separator, ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
1e60a99a-a816-54ec-a88f-dfa3921b05db | docs | python | python_stdtypes | 315 | 152 | removed. The *bytes* argument is a binary sequence specifying the set of
byte values to be removed. If omitted or `None`, the *bytes*
argument defaults to removing ASCII whitespace. The *bytes* argument is
not a prefix or suffix; rather, all combinations of its values are
stripped:
```None
... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
8d1b2f52-f327-5816-b38c-b656d33b0230 | docs | python | python_stdtypes | 315 | 153 | bytes.capitalize()[¶](#bytes.capitalize "Link to this definition")
bytearray.capitalize()[¶](#bytearray.capitalize "Link to this definition")
: Return a copy of the sequence with each byte interpreted as an ASCII
character, and the first byte capitalized and the rest lowercased.
Non-ASCII byte values are pas... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
92eed8d2-2ec2-5274-b0b8-87129529d68b | docs | python | python_stdtypes | 315 | 154 | sequence, the current column is set to zero and the sequence is examined
byte by byte. If the byte is an ASCII tab character (`b'\t'`), one or
more space characters are inserted in the result until the current column
is equal to the next tab position. (The tab character itself is not
copied.) If the... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
86362f33-09c5-5112-b736-3d6b493064f1 | docs | python | python_stdtypes | 315 | 155 | bytearray.isalnum()[¶](#bytearray.isalnum "Link to this definition")
: Return `True` if all bytes in the sequence are alphabetical ASCII characters
or ASCII decimal digits and the sequence is not empty, `False` otherwise.
Alphabetic ASCII characters are those byte values in the sequence
`b'abcdefghijklmno... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
405eeccb-aaa4-56ac-87ef-d55c04735179 | docs | python | python_stdtypes | 315 | 156 | >>> b'ABCabc1'.isalpha()
False
```
bytes.isascii()[¶](#bytes.isascii "Link to this definition")
bytearray.isascii()[¶](#bytearray.isascii "Link to this definition")
: Return `True` if the sequence is empty or all bytes in the sequence are ASCII,
`False` otherwise.
ASCII bytes are in the range 0-... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
b0ffdc4a-66f3-520f-93c4-13528c8baba9 | docs | python | python_stdtypes | 315 | 157 | in the sequence and no uppercase ASCII characters, `False` otherwise.
For example:
```None
>>> b'hello world'.islower()
True
>>> b'Hello world'.islower()
False
```
Lowercase ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
532ad4d8-e26a-57e0-971c-4153b184af77 | docs | python | python_stdtypes | 315 | 158 | : Return `True` if the sequence is ASCII titlecase and the sequence is not
empty, `False` otherwise. See [`bytes.title()`](#bytes.title "bytes.title") for more details on the
definition of “titlecase”.
For example:
```None
>>> b'Hello World'.istitle()
True
>>> b'Hello world'.istitle()
... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
0d0e11c7-1fe6-5620-a3d3-22739b51fba2 | docs | python | python_stdtypes | 315 | 159 | bytearray.lower()[¶](#bytearray.lower "Link to this definition")
: Return a copy of the sequence with all the uppercase ASCII characters
converted to their corresponding lowercase counterpart.
For example:
```None
>>> b'Hello World'.lower()
b'hello world'
```
Lowercase ASCII characters ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
b94e4548-7777-5be9-b8c2-82558c914ae5 | docs | python | python_stdtypes | 315 | 160 | to splitting lines. Line breaks are not included in the resulting list
unless *keepends* is given and true.
For example:
```None
>>> b'ab c\n\nde fg\rkl\r\n'.splitlines()
[b'ab c', b'', b'de fg', b'kl']
>>> b'ab c\n\nde fg\rkl\r\n'.splitlines(keepends=True)
[b'ab c\n', b'\n', b'de fg\r... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
c0442e83-5b87-5d8a-9b1c-dbbe862849a1 | docs | python | python_stdtypes | 315 | 161 | converted to their corresponding uppercase counterpart and vice-versa.
For example:
```None
>>> b'Hello World'.swapcase()
b'hELLO wORLD'
```
Lowercase ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII characters
are those byte ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
e38e2969-6a20-5d6b-9821-6fb03c216759 | docs | python | python_stdtypes | 315 | 162 | an uppercase ASCII character and the remaining characters are lowercase.
Uncased byte values are left unmodified.
For example:
```None
>>> b'Hello world'.title()
b'Hello World'
```
Lowercase ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyz'`. Up... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
8a62c968-b823-53a1-8669-a1c47476b7bf | docs | python | python_stdtypes | 315 | 163 | ... return re.sub(rb"[A-Za-z]+('[A-Za-z]+)?",
... lambda mo: mo.group(0)[0:1].upper() +
... mo.group(0)[1:].lower(),
... s)
...
>>> titlecase(b"they're bill's friends.")
b"They're Bill's Friends."
```
Note
The... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
0ec02be9-0392-5e77-b7cc-5ad3f36548fe | docs | python | python_stdtypes | 315 | 164 | The bytearray version of this method does *not* operate in place - it
always produces a new object, even if no changes were made.
bytes.zfill(*width*, */*)[¶](#bytes.zfill "Link to this definition")
bytearray.zfill(*width*, */*)[¶](#bytearray.zfill "Link to this definition")
: Return a copy of the sequence ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
6745d5bd-f76a-5b45-b935-987b1f8b8b71 | docs | python | python_stdtypes | 315 | 165 | ### `printf`-style Bytes Formatting[¶](#printf-style-bytes-formatting "Link to this heading")
Note
The formatting operations described here exhibit a variety of quirks that
lead to a number of common errors (such as failing to display tuples and
dictionaries correctly). If the value being printed may be a tuple or
di... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
d5c5c688-4118-5de1-826f-446a86245751 | docs | python | python_stdtypes | 315 | 166 | A conversion specifier contains two or more characters and has the following
components, which must occur in this order:
1. The `'%'` character, which marks the start of the specifier.
2. Mapping key (optional), consisting of a parenthesised sequence of characters
(for example, `(somename)`).
3. Conversion flags (o... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
7ec73546-159b-50b7-af22-2eb21932dfe8 | docs | python | python_stdtypes | 315 | 167 | formats in the bytes object *must* include a parenthesised mapping key into that
dictionary inserted immediately after the `'%'` character. The mapping key
selects the value to be formatted from the mapping. For example:
```None
>>> print(b'%(language)s has %(number)03d quote types.' %
... {b'language': b"Python... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
b6152512-8f81-5fe9-a339-fedb6b8d9f00 | docs | python | python_stdtypes | 315 | 168 |
A length modifier (`h`, `l`, or `L`) may be present, but is ignored as it
is not necessary for Python – so e.g. `%ld` is identical to `%d`.
The conversion types are:
| Conversion | Meaning | Notes |
| --- | --- | --- |
| `'d'` | Signed integer decimal. | |
| `'i'` | Signed integer decimal. | |
| `'o'` | Signed oct... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
026bd472-d8d9-56d5-87eb-d0319824ea1e | docs | python | python_stdtypes | 315 | 169 | | `'G'` | Floating-point format. Uses uppercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. | (4) |
| `'c'` | Single byte (accepts integer or single byte objects). | |
| `'b'` | Bytes (any object that follows the [buffer protocol](../c-api/buffer.html#bufferobje... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
6fb433a7-4367-5202-96c7-39e4ce8f5b25 | docs | python | python_stdtypes | 315 | 170 | the `'x'` or `'X'` format was used) to be inserted before the first digit.
3. The alternate form causes the result to always contain a decimal point, even if
no digits follow it.
The precision determines the number of digits after the decimal point and
defaults to 6.
4. The alternate form causes the result... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
a3510280-d83d-50dd-82f9-6c6f5f8382d1 | docs | python | python_stdtypes | 315 | 171 | [**PEP 461**](https://peps.python.org/pep-0461/) - Adding % formatting to bytes and bytearray
Added in version 3.5.
### Memory Views[¶](#memory-views "Link to this heading")
[`memoryview`](#memoryview "memoryview") objects allow Python code to access the internal data
of an object that supports the [buffer protocol]... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
ab89ad4c-ce25-53d6-b8f5-9342f93bedb0 | docs | python | python_stdtypes | 315 | 172 | byte, but other types such as [`array.array`](array.html#array.array "array.array") may have bigger elements.
`len(view)` is equal to the length of [`tolist`](#memoryview.tolist "memoryview.tolist"), which
is the nested list representation of the view. If `view.ndim = 1`,
this is equal to the number of... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
4e646569-360f-584b-bfa3-25a4b73c4e93 | docs | python | python_stdtypes | 315 | 173 | If [`format`](#memoryview.format "memoryview.format") is one of the native format specifiers
from the [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module, indexing with an integer or a tuple of
integers is also supported and returns a single *element* with
the c... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
27079343-07f9-56bf-bec2-d1ba88d7c4bd | docs | python | python_stdtypes | 315 | 174 | one-dimensional slice assignment. Resizing is not allowed:
```None
>>> data = bytearray(b'abcefg')
>>> v = memoryview(data)
>>> v.readonly
False
>>> v[0] = ord(b'z')
>>> data
bytearray(b'zbcefg')
>>> v[1:4] = b'123'
>>> data
bytearray(b'z123fg')
>>> v[2:3] = b'spam'
... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
f2783642-b28d-511a-bb7f-ef267a45795e | docs | python | python_stdtypes | 315 | 175 | Changed in version 3.3: One-dimensional memoryviews can now be sliced.
One-dimensional memoryviews with formats ‘B’, ‘b’ or ‘c’ are now [hashable](../glossary.html#term-hashable).
Changed in version 3.4: memoryview is now registered automatically with
[`collections.abc.Sequence`](collections.abc.html#c... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
16fa74df-a59e-553e-af0b-a8ec2d4867d2 | docs | python | python_stdtypes | 315 | 176 | respective format codes are interpreted using [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") syntax.
For the subset of [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") format strings currently supported by
[`tolist()`... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
654ad27e-256f-5426-a107-7583f82849b6 | docs | python | python_stdtypes | 315 | 177 | If either format string is not supported by the [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module,
then the objects will always compare as unequal (even if the format
strings and buffer contents are identical):
```None
>>> from ctypes ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
e50212bb-a4df-57ba-a61b-1f9d8778a478 | docs | python | python_stdtypes | 315 | 178 | : Return the data in the buffer as a bytestring. This is equivalent to
calling the [`bytes`](#bytes "bytes") constructor on the memoryview.
```None
>>> m = memoryview(b"abc")
>>> m.tobytes()
b'abc'
>>> bytes(m)
b'abc'
```
For non-contiguous... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
b4efa6ad-9554-5bc0-bf6d-11d88ea958e2 | docs | python | python_stdtypes | 315 | 179 | data is converted to C first. *order=None* is the same as *order=’C’*.
hex(*\**, *bytes\_per\_sep=1*)[¶](#memoryview.hex "Link to this definition")
hex(*sep*, *bytes\_per\_sep=1*)
: Return a string object containing two hexadecimal digits for each
byte in the buffer.
```None
... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
ad759f01-b84a-58d8-9a03-923565cef4e8 | docs | python | python_stdtypes | 315 | 180 | >>> m.tolist()
[1.1, 2.2, 3.3]
```
Changed in version 3.3: [`tolist()`](#memoryview.tolist "memoryview.tolist") now supports all single character native formats in
[`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module syntax as well as mul... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
40c46950-2210-5a9d-971b-dbe02751f626 | docs | python | python_stdtypes | 315 | 181 | : Release the underlying buffer exposed by the memoryview object. Many
objects take special actions when a view is held on them (for example,
a [`bytearray`](#bytearray "bytearray") would temporarily forbid resizing); therefore,
calling release() is handy to remove these restrictions (and ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
0765dec4-de75-5800-a4c3-e183b4eca5f6 | docs | python | python_stdtypes | 315 | 182 | ```None
>>> with memoryview(b'abc') as m:
... m[0]
...
97
>>> m[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: operation forbidden on released memoryview object
```
Added in version 3.2.... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
a8c6b23f-f849-5f1b-9dae-d3125eda6959 | docs | python | python_stdtypes | 315 | 183 | (‘B’, ‘b’ or ‘c’). The byte length of the result must be the same
as the original length.
Note that all byte lengths may depend on the operating system.
Cast 1D/long to 1D/unsigned bytes:
```None
>>> import array
>>> a = array.array('l', [1,2,3])
>>> x =... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
f8093ded-e82d-5011-a9cf-b42d286cddf3 | docs | python | python_stdtypes | 315 | 184 | Cast 1D/bytes to 3D/ints to 1D/signed char:
```None
>>> import struct
>>> buf = struct.pack("i"*12, *list(range(12)))
>>> x = memoryview(buf)
>>> y = x.cast('i', shape=[2,2,3])
>>> y.tolist()
[[[0, 1, 2], [3, 4, 5]], [[6, 7, 8], [9, 10, 11]]]
>>> ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
57d439d1-ba1e-5c6d-b9d7-57ae75f336d8 | docs | python | python_stdtypes | 315 | 185 | Changed in version 3.5: The source format is no longer restricted when casting to a byte view.
count(*value*, */*)[¶](#memoryview.count "Link to this definition")
: Count the number of occurrences of *value*.
Added in version 3.14.
index(*value*, *start=0*, *stop=sys.maxsize*, */*)[¶](#... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
9c4bb1f8-ed23-5c97-a8ff-1a59369baa46 | docs | python | python_stdtypes | 315 | 186 | : `nbytes == product(shape) * itemsize == len(m.tobytes())`. This is
the amount of space in bytes that the array would use in a contiguous
representation. It is not necessarily equal to `len(m)`:
```None
>>> import array
>>> a = array.array('i', [1,2,3,4,5])
>>> m ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
4f64585d-7c7f-5023-85ae-48d386aaede1 | docs | python | python_stdtypes | 315 | 187 | : A bool indicating whether the memory is read only.
format[¶](#memoryview.format "Link to this definition")
: A string containing the format (in [`struct`](struct.html#module-struct "struct: Interpret bytes as packed binary data.") module style) for each
element in the view. A memoryview can b... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
5b52f19c-ad0a-5e67-a858-7975616657dd | docs | python | python_stdtypes | 315 | 188 | >>> struct.calcsize('H') == m.itemsize
True
```
ndim[¶](#memoryview.ndim "Link to this definition")
: An integer indicating how many dimensions of a multi-dimensional array the
memory represents.
shape[¶](#memoryview.shape "Link to this definition")
: A tuple of int... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
a28ab883-7fba-5300-afb6-b690777f640d | docs | python | python_stdtypes | 315 | 189 | c\_contiguous[¶](#memoryview.c_contiguous "Link to this definition")
: A bool indicating whether the memory is C-[contiguous](../glossary.html#term-contiguous).
Added in version 3.3.
f\_contiguous[¶](#memoryview.f_contiguous "Link to this definition")
: A bool indicating whether the memory... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
8e271b46-4884-5b81-8448-1554ed1d2a9b | docs | python | python_stdtypes | 315 | 190 | (For other containers see the built-in [`dict`](#dict "dict"), [`list`](#list "list"),
and [`tuple`](#tuple "tuple") classes, and the [`collections`](collections.html#module-collections "collections: Container datatypes") module.)
Like other collections, sets support `x in set`, `len(set)`, and `for x in
set`. Being a... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
99f6c827-536f-5038-b1eb-1725f29025bf | docs | python | python_stdtypes | 315 | 191 | its contents cannot be altered after it is created;
it can therefore be used as a dictionary key or as an element of another set.
Non-empty sets (not frozensets) can be created by placing a comma-separated list
of elements within braces, for example: `{'jack', 'sjoerd'}`, in addition to the
[`set`](#set "set") constru... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
e40f6e28-688d-5192-9160-43facc5dd886 | docs | python | python_stdtypes | 315 | 192 | * Use a set comprehension: `{c for c in 'abracadabra' if c not in 'abc'}`
* Use the type constructor: `set()`, `set('foobar')`, `set(['a', 'b', 'foo'])`
Instances of [`set`](#set "set") and [`frozenset`](#frozenset "frozenset") provide the following
operations:
len(s)
: Return the number of elements in set *s* (car... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
1af3322f-be94-5bf1-a7b7-993e5f7f799e | docs | python | python_stdtypes | 315 | 193 | : Test whether the set is a proper subset of *other*, that is,
`set <= other and set != other`.
frozenset.issuperset(*other*, */*)[¶](#frozenset.issuperset "Link to this definition")
set.issuperset(*other*, */*)[¶](#set.issuperset "Link to this definition")
set >= other
: Test whether every element in *other... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
628c1c0a-6825-55bf-bbe7-0e7cf7a10520 | docs | python | python_stdtypes | 315 | 194 | set.difference(*\*others*)[¶](#set.difference "Link to this definition")
set - other - ...
: Return a new set with elements in the set that are not in the others.
frozenset.symmetric\_difference(*other*, */*)[¶](#frozenset.symmetric_difference "Link to this definition")
set.symmetric\_difference(*other*, */*)[¶](#... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
3afde8d7-a22b-587b-970e-d25a6944ae30 | docs | python | python_stdtypes | 315 | 195 | [`issuperset()`](#frozenset.issuperset "frozenset.issuperset") methods will accept any iterable as an argument. In
contrast, their operator based counterparts require their arguments to be
sets. This precludes error-prone constructions like `set('abc') & 'cbs'`
in favor of the more readable `set('abc').intersection('cb... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
a43292d2-8833-5f35-b5a0-bbe0d28aab09 | docs | python | python_stdtypes | 315 | 196 | returns `True` and so does `set('abc') in set([frozenset('abc')])`.
The subset and equality comparisons do not generalize to a total ordering
function. For example, any two nonempty disjoint sets are not equal and are not
subsets of each other, so *all* of the following return `False`: `a<b`,
`a==b`, or `a>b`.
Since ... | large_dataset/raw/docs/python/stdtypes/stdtypes_315.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.