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 |
|---|---|---|---|---|---|---|---|
a63aa53b-a1d9-5bf8-8cd2-47abda92cc23 | docs | python | python_stdtypes | 310 | 59 | or a [debug build](../using/configure.html#debug-build) is used.
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-b... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
b32c4489-be7a-5627-852f-19181d5b7e75 | docs | python | python_stdtypes | 310 | 60 | positions at columns 0, 8, 16 and so on). To expand the string, the current
column is set to zero and the string is examined character by character. If
the character is a tab (`\t`), one or more space characters are inserted
in the result until the current column is equal to the next tab position.
(... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
cfb57a51-7cf8-5104-8e63-b1b654fa8144 | docs | python | python_stdtypes | 310 | 61 | the slice `s[start:end]`. Optional arguments *start* and *end* are
interpreted as in slice notation. Return `-1` if *sub* is not found.
Note
The [`find()`](#str.find "str.find") method should be used only if you need to know the
position of *sub*. To check if *sub* is a substring or not, use the
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
d3214370-00d4-5595-88ed-8cf3e082fa1a | docs | python | python_stdtypes | 310 | 62 | ```
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 "com... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
aa90c420-6978-52ea-aa29-338732a982cf | docs | python | python_stdtypes | 310 | 63 | `str.``format_map`(*mapping*)[¶](#str.format_map "Permalink 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_310.md |
dd5d7f5b-7994-54c8-a084-5aec7ade850c | docs | python | python_stdtypes | 310 | 64 | of the following returns `True`: `c.isalpha()`, `c.isdecimal()`,
`c.isdigit()`, or `c.isnumeric()`.
`str.``isalpha`()[¶](#str.isalpha "Permalink to this definition")
: Return `True` if all characters in the string are alphabetic and there is at least
one character, `False` otherwise. Alphabetic character... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
a789b9b6-2d1d-5559-9720-df6fc5872593 | docs | python | python_stdtypes | 310 | 65 | characters and there is at least one character, `False`
otherwise. Decimal characters are those that can be used to form
numbers in base 10, e.g. U+0660, ARABIC-INDIC DIGIT
ZERO. Formally a decimal character is a character in the Unicode
General Category “Nd”.
`str.``isdigit`()[¶](#str.isdigit "Per... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
7df04b98-83c6-5fbe-9620-f843bd6a15b0 | docs | python | python_stdtypes | 310 | 66 | definition, section [Identifiers and keywords](../reference/lexical_analysis.html#identifiers).
Call [`keyword.iskeyword()`](keyword.html#keyword.iskeyword "keyword.iskeyword") to test whether string `s` is a reserved
identifier, such as [`def`](../reference/compound_stmts.html#def) and [`class`](../refere... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
1b3c2092-3d0e-51a2-b698-b2edb6995f84 | docs | python | python_stdtypes | 310 | 67 | 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, Numeric\_Type=Decimal or Numeric\_Type=Numeric.
`str.``isp... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
4aa9df47-a657-563d-9fc9-36a16b109798 | docs | python | python_stdtypes | 310 | 68 | `str.``isspace`()[¶](#str.isspace "Permalink 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`](unicodedata.html#module-uni... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
e1b78947-979b-51bf-9bd3-82d883872bc5 | docs | python | python_stdtypes | 310 | 69 | ```None
>>> 'BANANA'.isupper()
True
>>> 'banana'.isupper()
False
>>> 'baNana'.isupper()
False
>>> ' '.isupper()
False
```
`str.``join`(*iterable*)[¶](#str.join "Permalink to this definition")
: Return a string which is the concatenation of the strings in *iterable*.
A [`Ty... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
9381a14a-d7f3-59f6-a96d-e87e85df0785 | docs | python | python_stdtypes | 310 | 70 | lowercase.
The lowercasing algorithm used is described in section 3.13 of the Unicode
Standard.
`str.``lstrip`([*chars*])[¶](#str.lstrip "Permalink 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... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6596ef71-b25b-5ad6-948b-0fadbb6a752d | docs | python | python_stdtypes | 310 | 71 | *static* `str.``maketrans`(*x*[, *y*[, *z*]])[¶](#str.maketrans "Permalink to this definition")
: 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 charac... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
8c41a157-5707-58f2-896c-733fd40b110e | docs | python | python_stdtypes | 310 | 72 | after the separator. If the separator is not found, return a 3-tuple containing
the string itself, followed by two empty strings.
`str.``removeprefix`(*prefix*, */*)[¶](#str.removeprefix "Permalink to this definition")
: If the string starts with the *prefix* string, return
`string[len(prefix):]`. Otherw... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
9fb1356b-b89d-541f-86da-a771571d9a2e | docs | python | python_stdtypes | 310 | 73 | `str.``replace`(*old*, *new*[, *count*])[¶](#str.replace "Permalink to this definition")
: Return a copy of the string with all occurrences of substring *old* replaced by
*new*. If the optional argument *count* is given, only the first *count*
occurrences are replaced.
`str.``rfind`(*sub*[, *start*[, *end*]]... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
980b6c1b-0606-5f76-97a2-6d3d19ffb326 | docs | python | python_stdtypes | 310 | 74 | 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.``rpartition`(*sep*)[¶](#str.rpartition "Permalink to this definition")
: Split the string at the last occurrence of *sep*, and return a 3-tuple
containing t... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
4bf0e886-6e25-59e5-ad06-7f49e6d7ae3f | docs | python | python_stdtypes | 310 | 75 | [`split()`](#str.split "str.split") which is described in detail below.
`str.``rstrip`([*chars*])[¶](#str.rstrip "Permalink to this definition")
: Return a copy of the string with trailing characters removed. The *chars*
argument is a string specifying the set of characters to be removed. If omitted
or `... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
5dcc9197-e18b-5959-9253-a660d34ea811 | docs | python | python_stdtypes | 310 | 76 | : 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 (thus,
the list will have at most `maxsplit+1` elements). If *maxsplit* is not
specified or `-1`, then there is no limit on the number of splits
(all possible spl... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
53200ad3-0127-5657-9ccb-4c2ac992f49f | docs | python | python_stdtypes | 310 | 77 | applied: runs of consecutive whitespace are regarded as a single separator,
and the result will contain no empty strings at the start or end if the
string has leading or trailing whitespace. Consequently, splitting an empty
string or a string consisting of just whitespace with a `None` separator
ret... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
bd52d935-4fe0-5c68-96ba-ac48a2d723bf | docs | python | python_stdtypes | 310 | 78 | | `\n` | Line Feed |
| `\r` | Carriage Return |
| `\r\n` | Carriage Return + Line Feed |
| `\v` or `\x0b` | Line Tabulation |
| `\f` or `\x0c` | Form Feed |
| `\x1c` | File Separator |
| `\x1d` | Group Separator |
| `\x1e` | Record Separator |
| `\x85` | Next Line (C1 Control Code) |... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
06590a94-ae24-5d5a-8fe7-d493a5d1d043 | docs | python | python_stdtypes | 310 | 79 | For comparison, `split('\n')` gives:
```None
>>> ''.split('\n')
['']
>>> 'Two lines\n'.split('\n')
['Two lines', '']
```
`str.``startswith`(*prefix*[, *start*[, *end*]])[¶](#str.startswith "Permalink to this definition")
: Return `True` if string starts with the *prefix*, otherwise retur... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
c8016bc3-523f-5e73-9d3d-baccdaba5eeb | docs | python | python_stdtypes | 310 | 80 | >>> 'www.example.com'.strip('cmowz.')
'example'
```
The outermost leading and trailing *chars* argument values are stripped
from the string. Characters are removed from the leading end until
reaching a string character that is not contained in the set of
characters in *chars*. A similar act... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
761c36b3-5fa6-5c8e-bfb8-a9003746eab2 | docs | python | python_stdtypes | 310 | 81 | >>> 'Hello world'.title()
'Hello World'
```
The algorithm uses a simple language-independent definition of a word as
groups of consecutive letters. The definition works in many contexts but
it means that apostrophes in contractions and possessives form word
boundaries, which may not be the ... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6ba21256-da35-5e39-a8fd-e50ca57939ff | docs | python | python_stdtypes | 310 | 82 | `str.``translate`(*table*)[¶](#str.translate "Permalink to this definition")
: 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](../glossary.html#term-mapping)... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
b0add03b-5d7c-514b-9aa1-28636a7cae46 | docs | python | python_stdtypes | 310 | 83 | See also the [`codecs`](codecs.html#module-codecs "codecs: Encode and decode data and streams.") module for a more flexible approach to custom
character mappings.
`str.``upper`()[¶](#str.upper "Permalink to this definition")
: Return a copy of the string with all the cased characters [4](#id15) converted to
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
7d99ebfc-0910-52af-9a5c-53cad40e5019 | docs | python | python_stdtypes | 310 | 84 | or equal to `len(s)`.
For example:
```None
>>> "42".zfill(5)
'00042'
>>> "-42".zfill(5)
'-0042'
```
### `printf`-style String Formatting[¶](#printf-style-string-formatting "Permalink to this headline")
Note
The formatting operations described here exhibit a variety of quirks that
le... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
955c8fcb-719e-5953-91cc-ab43023c3058 | docs | python | python_stdtypes | 310 | 85 | specifications in *format* are replaced with zero or more elements of *values*.
The effect is similar to using the `sprintf()` in the C language.
If *format* requires a single argument, *values* may be a single non-tuple
object. [5](#id16) Otherwise, *values* must be a tuple with exactly the number of
items specified ... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
31adda65-6d34-59a5-992b-b22ee99eeb76 | docs | python | python_stdtypes | 310 | 86 | 5. Precision (optional), given as a `'.'` (dot) followed by the precision. If
specified as `'*'` (an asterisk), the actual precision is read from the next
element of the tuple in *values*, and the value to convert comes after the
precision.
6. Length modifier (optional).
7. Conversion type.
When the right arg... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
5e7221c0-3116-5e92-9b8e-188781589744 | docs | python | python_stdtypes | 310 | 87 | | `'0'` | The conversion will be zero padded for numeric values. |
| `'-'` | The converted value is left adjusted (overrides the `'0'` conversion if both are given). |
| `' '` | (a space) A blank should be left before a positive number (or empty string) produced by a signed conversion. |
| `'+'` | A sign character (`'+... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
8b4f5d93-4d00-5642-88b7-986485dcb542 | docs | python | python_stdtypes | 310 | 88 | | `'f'` | Floating point decimal format. | (3) |
| `'F'` | Floating point decimal format. | (3) |
| `'g'` | Floating point format. Uses lowercase exponential format if exponent is less than -4 or not less than precision, decimal format otherwise. | (4) |
| `'G'` | Floating point format. Uses uppercase exponential forma... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
838b9271-15e5-574f-87ca-24f504a9f849 | docs | python | python_stdtypes | 310 | 89 | 2. The alternate form causes a leading `'0x'` or `'0X'` (depending on whether
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 t... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
bba55f98-894e-59c0-9212-99413af839a2 | docs | python | python_stdtypes | 310 | 90 | ## Binary Sequence Types — [`bytes`](#bytes "bytes"), [`bytearray`](#bytearray "bytearray"), [`memoryview`](#memoryview "memoryview")[¶](#binary-sequence-types-bytes-bytearray-memoryview "Permalink to this headline")
The core built-in types for manipulating binary data are [`bytes`](#bytes "bytes") and
[`bytearray`](#... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
d060c369-7ab9-5764-8abc-28410bea0f8d | docs | python | python_stdtypes | 310 | 91 | several methods that are only valid when working with ASCII compatible
data and are closely related to string objects in a variety of other ways.
*class* `bytes`([*source*[, *encoding*[, *errors*]]])[¶](#bytes "Permalink to this definition")
: Firstly, the syntax for bytes literals is largely the same as that for st... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
8d4bffa5-2977-56a0-958c-4144bc7f8932 | docs | python | python_stdtypes | 310 | 92 | forms of bytes literal, including supported escape sequences.
While bytes literals and representations are based on ASCII text, bytes
objects actually behave like immutable sequences of integers, with each
value in the sequence restricted such that `0 <= x < 256` (attempts to
violate this restricti... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
78d18612-2a36-558f-98fd-bb787ea88e4c | docs | python | python_stdtypes | 310 | 93 | * Copying existing binary data via the buffer protocol: `bytes(obj)`
Also see the [bytes](functions.html#func-bytes) built-in.
Since 2 hexadecimal digits correspond precisely to a single byte, hexadecimal
numbers are a commonly used format for describing binary data. Accordingly,
the bytes type ha... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
89598c0f-41e3-54ac-b18b-56a7206f457a | docs | python | python_stdtypes | 310 | 94 | hexadecimal representation.
`hex`([*sep*[, *bytes\_per\_sep*]])[¶](#bytes.hex "Permalink to this definition")
: Return a string object containing two hexadecimal digits for each
byte in the instance.
```None
>>> b'\xf0\xf1\xf2'.hex()
'f0f1f2'
```
If you w... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6f9440d9-0d35-5721-9175-a82ef5e972d2 | docs | python | python_stdtypes | 310 | 95 | Changed in version 3.8: [`bytes.hex()`](#bytes.hex "bytes.hex") now supports optional *sep* and *bytes\_per\_sep*
parameters to insert separators between bytes in the hex output.
Since bytes objects are sequences of integers (akin to a tuple), for a bytes
object *b*, `b[0]` will be an integer, while `b... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
251af212-4da6-529b-b8b1-d0c9b976661f | docs | python | python_stdtypes | 310 | 96 | : There is no dedicated literal syntax for bytearray objects, instead
they are always created by calling the constructor:
* Creating an empty instance: `bytearray()`
* Creating a zero-filled instance with a given length: `bytearray(10)`
* From an iterable of integers: `bytearray(range(20))`
* Cop... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
11c7c1c7-9785-5ad8-8f52-a7511cc360ed | docs | python | python_stdtypes | 310 | 97 | *classmethod* `fromhex`(*string*)[¶](#bytearray.fromhex "Permalink to this definition")
: This [`bytearray`](#bytearray "bytearray") class method returns bytearray object, decoding
the given string object. The string must contain two hexadecimal digits
per byte, with ASCII whitespace being ign... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
c1986c0c-9ac8-5729-87d5-c9f8ce5a3881 | docs | python | python_stdtypes | 310 | 98 | New 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 separators
between bytes in the hex output.
Since bytearray objects... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6da82765-858b-5dfd-99e2-224ecc832ac1 | docs | python | python_stdtypes | 310 | 99 | ### Bytes and Bytearray Operations[¶](#bytes-and-bytearray-operations "Permalink to this headline")
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-o... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
1f779ccb-3c70-5f9f-9ddd-5b911c758cbc | docs | python | python_stdtypes | 310 | 100 | 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 "Permalink to this definition")
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6b6c5ba4-aa0a-503d-9d28-c558bafc80b2 | docs | python | python_stdtypes | 310 | 101 | `bytes.``removeprefix`(*prefix*, */*)[¶](#bytes.removeprefix "Permalink to this definition")
`bytearray.``removeprefix`(*prefix*, */*)[¶](#bytearray.removeprefix "Permalink to this definition")
: If the binary data starts with the *prefix* string, return
`bytes[len(prefix):]`. Otherwise, return a copy of the ori... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6071849d-e0e5-51ec-a1e9-6cb489fffea8 | docs | python | python_stdtypes | 310 | 102 | 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_310.md |
363c50c9-2ced-5646-8d0c-802f54183e26 | docs | python | python_stdtypes | 310 | 103 | 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_310.md |
54b2b21f-b8cc-5fbc-bd09-c4d9d64638fa | docs | python | python_stdtypes | 310 | 104 | 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 "Permalink to this definition")
`bytearray.``endswith`(*suf... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
605254a7-ac92-565b-90ab-76f85f5c23c1 | docs | python | python_stdtypes | 310 | 105 | : 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_310.md |
f077f54f-cb6c-5288-bfff-2f50248203c7 | docs | python | python_stdtypes | 310 | 106 | : 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_310.md |
016cb9be-1fc4-5d18-b85c-040c133c9c09 | docs | python | python_stdtypes | 310 | 107 | *static* `bytes.``maketrans`(*from*, *to*)[¶](#bytes.maketrans "Permalink to this definition")
*static* `bytearray.``maketrans`(*from*, *to*)[¶](#bytearray.maketrans "Permalink to this definition")
: This static method returns a translation table usable for
[`bytes.translate()`](#bytes.translate "bytes.translate... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
09352568-c6c5-5c1f-b8f7-cba46272466c | docs | python | python_stdtypes | 310 | 108 | 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*])[¶](#bytes.replace "Permalink to this definition")
`bytearray.``repl... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
aa8aaeee-9f46-5417-96c1-a6c1b02ec138 | docs | python | python_stdtypes | 310 | 109 | `bytearray.``rfind`(*sub*[, *start*[, *end*]])[¶](#bytearray.rfind "Permalink 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. Ret... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
edb43b5e-f152-50bb-8701-9666c8aee6da | docs | python | python_stdtypes | 310 | 110 | 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 "Permalink to this definition... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
a85cb8a1-b786-5f4a-a30f-850636eb53a8 | docs | python | python_stdtypes | 310 | 111 | `bytearray.``startswith`(*prefix*[, *start*[, *end*]])[¶](#bytearray.startswith "Permalink 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 p... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
0a9ea086-49c8-5781-90d8-c4b73d5f5bff | docs | python | python_stdtypes | 310 | 112 | 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_310.md |
2de9b94c-08f4-53fd-8fb2-bea5046cf841 | docs | python | python_stdtypes | 310 | 113 | 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_310.md |
b6c4f0f0-6277-594a-b216-3e1083b1f1c4 | docs | python | python_stdtypes | 310 | 114 | `bytes.``lstrip`([*chars*])[¶](#bytes.lstrip "Permalink to this definition")
`bytearray.``lstrip`([*chars*])[¶](#bytearray.lstrip "Permalink to this definition")
: Return a copy of the sequence with specified leading bytes removed. The
*chars* argument is a binary sequence specifying the set of byte values to
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
0d14323b-357f-52fb-8c5e-a3129fbbeb19 | docs | python | python_stdtypes | 310 | 115 | characters. For example:
```None
>>> b'Arthur: three!'.lstrip(b'Arthur: ')
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... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6e4a5bb5-5922-55bc-871c-7e4cc096f852 | docs | python | python_stdtypes | 310 | 116 | `bytes.``rsplit`(*sep=None*, *maxsplit=- 1*)[¶](#bytes.rsplit "Permalink to this definition")
`bytearray.``rsplit`(*sep=None*, *maxsplit=- 1*)[¶](#bytearray.rsplit "Permalink to this definition")
: Split the binary sequence into subsequences of the same type, using *sep*
as the delimiter string. If *maxsplit* is... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
8ac0521e-a7fd-5839-9183-ec32d7ca477b | docs | python | python_stdtypes | 310 | 117 | be removed - the name refers to the fact this method is usually used with
ASCII characters. If omitted or `None`, the *chars* argument defaults to
removing ASCII whitespace. The *chars* argument is not a suffix; rather,
all combinations of its values are stripped:
```None
>>> b' spacious '.... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
a8f2c6c9-7c34-5f38-aedd-12ebeddba5db | docs | python | python_stdtypes | 310 | 118 | `bytes.``split`(*sep=None*, *maxsplit=- 1*)[¶](#bytes.split "Permalink to this definition")
`bytearray.``split`(*sep=None*, *maxsplit=- 1*)[¶](#bytearray.split "Permalink to this definition")
: Split the binary sequence into subsequences of the same type, using *sep*
as the delimiter string. If *maxsplit* is giv... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
3132fadf-5ce3-5bb3-81a0-f8cb4b097617 | docs | python | python_stdtypes | 310 | 119 | of object being split. The *sep* argument may be any
[bytes-like object](../glossary.html#term-bytes-like-object).
For example:
```None
>>> b'1,2,3'.split(b',')
[b'1', b'2', b'3']
>>> b'1,2,3'.split(b',', maxsplit=1)
[b'1', b'2,3']
>>> b'1,2,,3,'.split(b',')
[b'1', b'2', b'', b... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
abfed1a1-8d5c-5742-a0da-b8d723888b97 | docs | python | python_stdtypes | 310 | 120 | `bytes.``strip`([*chars*])[¶](#bytes.strip "Permalink to this definition")
`bytearray.``strip`([*chars*])[¶](#bytearray.strip "Permalink to this definition")
: Return a copy of the sequence with specified leading and trailing bytes
removed. The *chars* argument is a binary sequence specifying the set of
byte... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
437930f1-26a1-5ff1-b984-84df2bfdd42a | docs | python | python_stdtypes | 310 | 121 | it always produces a new object, even if no changes were made.
The following methods on bytes and bytearray objects assume the use of ASCII
compatible binary formats and should not be applied to arbitrary binary data.
Note that all of the bytearray methods in this section do *not* operate in
place, and instead pro... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
1fb10c92-95e7-56be-bcd5-24025bbf3a59 | docs | python | python_stdtypes | 310 | 122 | `bytearray.``expandtabs`(*tabsize=8*)[¶](#bytearray.expandtabs "Permalink to this definition")
: Return a copy of the sequence where all ASCII tab characters are replaced
by one or more ASCII spaces, depending on the current column and the given
tab size. Tab positions occur every *tabsize* bytes (default is ... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
a3a28d1f-38e8-570f-93e3-d6010535f30b | docs | python | python_stdtypes | 310 | 123 | >>> b'01\t012\t0123\t01234'.expandtabs()
b'01 012 0123 01234'
>>> b'01\t012\t0123\t01234'.expandtabs(4)
b'01 012 0123 01234'
```
Note
The bytearray version of this method does *not* operate in place - it
always produces a new object, even if no changes were made.
`byte... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
22f658e7-4a6e-5090-bdb9-54451437ed99 | docs | python | python_stdtypes | 310 | 124 | `bytearray.``isalpha`()[¶](#bytearray.isalpha "Permalink to this definition")
: Return `True` if all bytes in the sequence are alphabetic ASCII characters
and the sequence is not empty, `False` otherwise. Alphabetic ASCII
characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyzABCDEF... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
84b0dacc-8233-5610-a05f-80c9eecb7694 | docs | python | python_stdtypes | 310 | 125 | and the sequence is not empty, `False` otherwise. ASCII decimal digits are
those byte values in the sequence `b'0123456789'`.
For example:
```None
>>> b'1234'.isdigit()
True
>>> b'1.23'.isdigit()
False
```
`bytes.``islower`()[¶](#bytes.islower "Permalink to this definition")
`byt... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
c6da8365-aa5f-513d-a561-b6a82a770ab4 | docs | python | python_stdtypes | 310 | 126 | : Return `True` if all bytes in the sequence are ASCII whitespace and the
sequence is not empty, `False` otherwise. ASCII whitespace characters are
those byte values in the sequence `b' \t\n\r\x0b\f'` (space, tab, newline,
carriage return, vertical tab, form feed).
`bytes.``istitle`()[¶](#bytes.istitle "... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
12faedd3-3b4f-5fa2-904d-7449997746aa | docs | python | python_stdtypes | 310 | 127 | in the sequence and no lowercase ASCII characters, `False` otherwise.
For example:
```None
>>> b'HELLO WORLD'.isupper()
True
>>> b'Hello world'.isupper()
False
```
Lowercase ASCII characters are those byte values in the sequence
`b'abcdefghijklmnopqrstuvwxyz'`. Uppercase ASCII... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
c1e039bd-7d52-538a-a2a9-76ccdcc1753c | docs | python | python_stdtypes | 310 | 128 | The bytearray version of this method does *not* operate in place - it
always produces a new object, even if no changes were made.
`bytes.``splitlines`(*keepends=False*)[¶](#bytes.splitlines "Permalink to this definition")
`bytearray.``splitlines`(*keepends=False*)[¶](#bytearray.splitlines "Permalink to this d... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
f9a770fc-b36a-5ab5-8c39-a626baddd608 | docs | python | python_stdtypes | 310 | 129 | method returns an empty list for the empty string, and a terminal line
break does not result in an extra line:
```None
>>> b"".split(b'\n'), b"Two lines\n".split(b'\n')
([b''], [b'Two lines', b''])
>>> b"".splitlines(), b"One line\n".splitlines()
([], [b'One line'])
```
`bytes.``swapca... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6f4a6203-ea8c-5d3e-927f-d565e4862511 | docs | python | python_stdtypes | 310 | 130 | `bin.swapcase().swapcase() == bin` for the binary versions. Case
conversions are symmetrical in ASCII, even though that is not generally
true for arbitrary Unicode code points.
Note
The bytearray version of this method does *not* operate in place - it
always produces a new object, even if no c... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
26a9b82a-c834-52e8-bfe6-c3bb3137e5b8 | docs | python | python_stdtypes | 310 | 131 | The algorithm uses a simple language-independent definition of a word as
groups of consecutive letters. The definition works in many contexts but
it means that apostrophes in contractions and possessives form word
boundaries, which may not be the desired result:
```None
>>> b"they're bill's fri... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
229645dc-6566-55bc-a620-1455aeb0534b | docs | python | python_stdtypes | 310 | 132 | `bytes.``upper`()[¶](#bytes.upper "Permalink to this definition")
`bytearray.``upper`()[¶](#bytearray.upper "Permalink to this definition")
: Return a copy of the sequence with all the lowercase ASCII characters
converted to their corresponding uppercase counterpart.
For example:
```None
>>> b'Hell... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
507390cd-23d9-5edb-9d4c-44d7faeef0b5 | docs | python | python_stdtypes | 310 | 133 | `b'-'`) is handled by inserting the padding *after* the sign character
rather than before. For [`bytes`](#bytes "bytes") objects, the original sequence is
returned if *width* is less than or equal to `len(seq)`.
For example:
```None
>>> b"42".zfill(5)
b'00042'
>>> b"-42".zfill(5)
b... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
f122af8e-1883-5d49-a852-496d3810d696 | docs | python | python_stdtypes | 310 | 134 | Given `format % values` (where *format* is a bytes object), `%` conversion
specifications in *format* are replaced with zero or more elements of *values*.
The effect is similar to using the `sprintf()` in the C language.
If *format* requires a single argument, *values* may be a single non-tuple
object. [5](#id16) Othe... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
99462f3b-edba-5732-96a7-2de4d91e2e20 | docs | python | python_stdtypes | 310 | 135 | object to convert comes after the minimum field width and optional precision.
5. Precision (optional), given as a `'.'` (dot) followed by the precision. If
specified as `'*'` (an asterisk), the actual precision is read from the next
element of the tuple in *values*, and the value to convert comes after the
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
571fc67d-af3f-5d12-8690-32f2b587afe7 | docs | python | python_stdtypes | 310 | 136 | | `'#'` | The value conversion will use the “alternate form” (where defined below). |
| `'0'` | The conversion will be zero padded for numeric values. |
| `'-'` | The converted value is left adjusted (overrides the `'0'` conversion if both are given). |
| `' '` | (a space) A blank should be left before a positive numbe... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
cd5ad756-2887-5f48-ad7e-f2af7917b70b | docs | python | python_stdtypes | 310 | 137 | | `'e'` | Floating point exponential format (lowercase). | (3) |
| `'E'` | Floating point exponential format (uppercase). | (3) |
| `'f'` | Floating point decimal format. | (3) |
| `'F'` | Floating point decimal format. | (3) |
| `'g'` | Floating point format. Uses lowercase exponential format if exponent is less than ... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
1dc484dc-4118-5516-8e2c-982276e286f1 | docs | python | python_stdtypes | 310 | 138 | | `'r'` | `'r'` is an alias for `'a'` and should only be used for Python2/3 code bases. | (7) |
| `'%'` | No argument is converted, results in a `'%'` character in the result. | |
Notes:
1. The alternate form causes a leading octal specifier (`'0o'`) to be
inserted before the first digit.
2. The alternate form ca... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
78e6a0d7-985c-5d5b-90db-b3f453cdee4e | docs | python | python_stdtypes | 310 | 139 | 6. `b'%s'` is deprecated, but will not be removed during the 3.x series.
7. `b'%r'` is deprecated, but will not be removed during the 3.x series.
8. See [**PEP 237**](https://www.python.org/dev/peps/pep-0237).
Note
The bytearray version of this method does *not* operate in place - it
always produces a new object, eve... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
391cb4f7-209b-5d97-be4d-8813e40db51c | docs | python | python_stdtypes | 310 | 140 | protocol include [`bytes`](#bytes "bytes") and [`bytearray`](#bytearray "bytearray").
A [`memoryview`](#memoryview "memoryview") has the notion of an *element*, which is the
atomic memory unit handled by the originating *object*. For many simple
types such as [`bytes`](#bytes "bytes") and [`bytearray`]... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
3df8a0c3-18ff-5db5-a6e8-56661d01706d | docs | python | python_stdtypes | 310 | 141 | A [`memoryview`](#memoryview "memoryview") supports slicing and indexing to expose its data.
One-dimensional slicing will result in a subview:
```None
>>> v = memoryview(b'abcefg')
>>> v[1]
98
>>> v[-1]
103
>>> v[1:4]
<memory at 0x7f3ddc9f4350>
>>> bytes(v[1:4])
b'bce'
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
e7d00e63-db87-5bbb-8c8e-dcf7f6966b8e | docs | python | python_stdtypes | 310 | 142 | >>> import array
>>> a = array.array('l', [-11111111, 22222222, -33333333, 44444444])
>>> m = memoryview(a)
>>> m[0]
-11111111
>>> m[-1]
44444444
>>> m[::2].tolist()
[-11111111, -33333333]
```
If the underlying object is writable, the memoryview supports
one-dimensional ... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
c814501f-673f-537d-afd9-ab7888e59351 | docs | python | python_stdtypes | 310 | 143 | ‘B’, ‘b’ or ‘c’ are also hashable. The hash is defined as
`hash(m) == hash(m.tobytes())`:
```None
>>> v = memoryview(b'abcefg')
>>> hash(v) == hash(b'abcefg')
True
>>> hash(v[2:4]) == hash(b'ce')
True
>>> hash(v[::-2]) == hash(b'abcefg'[::-2])
True
```
Changed in versio... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
5d27ef99-81c2-57aa-88a3-4c9ffb42580e | docs | python | python_stdtypes | 310 | 144 | equivalent and if all corresponding values are equal when the operands’
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... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
6454071b-17c3-5fe4-90cc-5648d5a4dc77 | docs | python | python_stdtypes | 310 | 145 | 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_310.md |
7d6c5573-f06b-586e-9ab0-9edd49e7e575 | docs | python | python_stdtypes | 310 | 146 | : 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_310.md |
508e8cc2-b564-5187-b8d8-b9cf43b44cd1 | docs | python | python_stdtypes | 310 | 147 | data is converted to C first. *order=None* is the same as *order=’C’*.
`hex`([*sep*[, *bytes\_per\_sep*]])[¶](#memoryview.hex "Permalink to this definition")
: Return a string object containing two hexadecimal digits for each
byte in the buffer.
```None
>>> m = memoryview(b"a... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
e73ff835-9f27-5fee-840c-158d0a2d55fd | docs | python | python_stdtypes | 310 | 148 | [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 multi-dimensional
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
77165961-ebd6-5acb-93c6-41d8ca8d1c72 | docs | python | python_stdtypes | 310 | 149 | : 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_310.md |
6f729292-1003-581e-8bab-6b719e8a5562 | docs | python | python_stdtypes | 310 | 150 | ```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
```
New in version 3.2.
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
0b6ed48b-919f-5b5e-8135-873f9f36c7c1 | docs | python | python_stdtypes | 310 | 151 | (‘B’, ‘b’ or ‘c’). The byte length of the result must be the same
as the original length.
Cast 1D/long to 1D/unsigned bytes:
```None
>>> import array
>>> a = array.array('l', [1,2,3])
>>> x = memoryview(a)
>>> x.format
'l'
>>> x.itemsize
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
23489460-b116-57e8-876a-a009447aa706 | docs | python | python_stdtypes | 310 | 152 | ```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]]]
>>> y.format
'i'
>>> y.itemsize
4... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
934a19a1-de03-5da3-906a-9c5843b83def | docs | python | python_stdtypes | 310 | 153 | There are also several readonly attributes available:
`obj`[¶](#memoryview.obj "Permalink to this definition")
: The underlying object of the memoryview:
```None
>>> b = bytearray(b'xyz')
>>> m = memoryview(b)
>>> m.obj is b
True
```
New in versi... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
82ca50e3-a92f-5bac-b500-98fbf6b79ff3 | docs | python | python_stdtypes | 310 | 154 | >>> buf = struct.pack("d"*12, *[1.5*x for x in range(12)])
>>> x = memoryview(buf)
>>> y = x.cast('d', shape=[3,4])
>>> y.tolist()
[[0.0, 1.5, 3.0, 4.5], [6.0, 7.5, 9.0, 10.5], [12.0, 13.5, 15.0, 16.5]]
>>> len(y)
3
>>> y.nbytes
96
```
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
70075886-7142-5f03-8e9a-dc43805c15c9 | docs | python | python_stdtypes | 310 | 155 | Changed in version 3.3: format `'B'` is now handled according to the struct module syntax.
This means that `memoryview(b'abc')[0] == b'abc'[0] == 97`.
`itemsize`[¶](#memoryview.itemsize "Permalink to this definition")
: The size in bytes of each element of the memoryview:
```None
... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
fc86c1ca-3b35-5b2d-8bb9-cdb7bf199e6d | docs | python | python_stdtypes | 310 | 156 | Changed in version 3.3: An empty tuple instead of `None` when ndim = 0.
`strides`[¶](#memoryview.strides "Permalink to this definition")
: A tuple of integers the length of [`ndim`](#memoryview.ndim "memoryview.ndim") giving the size in bytes to
access each element for each dimension of the a... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
1d602b2b-7d06-581b-bb3b-7dfa9a5435f2 | docs | python | python_stdtypes | 310 | 157 | `contiguous`[¶](#memoryview.contiguous "Permalink to this definition")
: A bool indicating whether the memory is [contiguous](../glossary.html#term-contiguous).
New in version 3.3.
## Set Types — [`set`](#set "set"), [`frozenset`](#frozenset "frozenset")[¶](#set-types-set-frozenset "Permalink to thi... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
9e093247-9d9e-5db6-b6be-70924ca47b06 | docs | python | python_stdtypes | 310 | 158 | order of insertion. Accordingly, sets do not support indexing, slicing, or
other sequence-like behavior.
There are currently two built-in set types, [`set`](#set "set") and [`frozenset`](#frozenset "frozenset").
The [`set`](#set "set") type is mutable — the contents can be changed using methods
like `add()` and `remov... | large_dataset/raw/docs/python/stdtypes/stdtypes_310.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.