package np

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `Bytes_
]
type t = [ `Bytes_ | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val create : Py.Object.t -> t

bytes(iterable_of_ints) -> bytes bytes(string, encoding, errors) -> bytes bytes(bytes_or_buffer) -> immutable copy of bytes_or_buffer bytes(int) -> bytes object of size given by the parameter initialized with null bytes bytes() -> empty bytes object

Construct an immutable array of bytes from:

  • an iterable yielding integers in range(256)
  • a text string encoded using the specified encoding
  • any object implementing the buffer API.
  • an integer
val __getitem__ : key:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return selfkey.

val __iter__ : [> tag ] Obj.t -> Py.Object.t

Implement iter(self).

val center : ?fillchar:Py.Object.t -> width:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a centered string of length width.

Padding is done using the specified fill character.

val count : ?start:Py.Object.t -> ?end_:Py.Object.t -> sub:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.count(sub, start[, end]) -> int

Return the number of non-overlapping occurrences of subsection sub in bytes Bstart:end. Optional arguments start and end are interpreted as in slice notation.

val decode : ?encoding:Py.Object.t -> ?errors:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Decode the bytes using the codec registered for encoding.

encoding The encoding with which to decode the bytes. errors The error handling scheme to use for the handling of decoding errors. The default is 'strict' meaning that decoding errors raise a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

val endswith : ?start:Py.Object.t -> ?end_:Py.Object.t -> suffix:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.endswith(suffix, start[, end]) -> bool

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

val expandtabs : ?tabsize:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

val find : ?start:Py.Object.t -> ?end_:Py.Object.t -> sub:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.find(sub, start[, end]) -> int

Return the lowest index in B where subsection sub is found, such that sub is contained within Bstart,end. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

val fromhex : string:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Create a bytes object from a string of hexadecimal numbers.

Spaces between two numbers are accepted. Example: bytes.fromhex('B9 01EF') -> b'\\xb9\\x01\\xef'.

val index : ?start:Py.Object.t -> ?end_:Py.Object.t -> sub:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.index(sub, start[, end]) -> int

Return the lowest index in B where subsection sub is found, such that sub is contained within Bstart,end. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when the subsection is not found.

val join : iterable_of_bytes:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Concatenate any number of bytes objects.

The bytes whose method is called is inserted in between each pair.

The result is returned as a new bytes object.

Example: b'.'.join(b'ab', b'pq', b'rs') -> b'ab.pq.rs'.

val ljust : ?fillchar:Py.Object.t -> width:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a left-justified string of length width.

Padding is done using the specified fill character.

val lstrip : ?bytes:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

val newbyteorder : ?new_order:string -> [> tag ] Obj.t -> Dtype.t

newbyteorder(new_order='S')

Return a new `dtype` with a different byte order.

Changes are also made in all fields and sub-arrays of the data type.

The `new_order` code can be any from the following:

* 'S' - swap dtype from current to opposite endian * '<', 'L' - little endian * '>', 'B' - big endian * '=', 'N' - native order * '|', 'I' - ignore (no change to byte order)

Parameters ---------- new_order : str, optional Byte order to force; a value from the byte order specifications above. The default value ('S') results in swapping the current byte order. The code does a case-insensitive check on the first letter of `new_order` for the alternatives above. For example, any of 'B' or 'b' or 'biggish' are valid to specify big-endian.

Returns ------- new_dtype : dtype New `dtype` object with the given change to the byte order.

val partition : sep:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

val replace : ?count:Py.Object.t -> old:Py.Object.t -> new_:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a copy with all occurrences of substring old replaced by new.

count Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

val rfind : ?start:Py.Object.t -> ?end_:Py.Object.t -> sub:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.rfind(sub, start[, end]) -> int

Return the highest index in B where subsection sub is found, such that sub is contained within Bstart,end. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

val rindex : ?start:Py.Object.t -> ?end_:Py.Object.t -> sub:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.rindex(sub, start[, end]) -> int

Return the highest index in B where subsection sub is found, such that sub is contained within Bstart,end. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when the subsection is not found.

val rjust : ?fillchar:Py.Object.t -> width:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a right-justified string of length width.

Padding is done using the specified fill character.

val rpartition : sep:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

val rsplit : ?sep:Py.Object.t -> ?maxsplit:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a list of the sections in the bytes, using sep as the delimiter.

sep The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab). maxsplit Maximum number of splits to do. -1 (the default value) means no limit.

Splitting is done starting at the end of the bytes and working to the front.

val rstrip : ?bytes:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

val split : ?sep:Py.Object.t -> ?maxsplit:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a list of the sections in the bytes, using sep as the delimiter.

sep The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab). maxsplit Maximum number of splits to do. -1 (the default value) means no limit.

val splitlines : ?keepends:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a list of the lines in the bytes, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

val startswith : ?start:Py.Object.t -> ?end_:Py.Object.t -> prefix:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

B.startswith(prefix, start[, end]) -> bool

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

val strip : ?bytes:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Strip leading and trailing bytes contained in the argument.

If the argument is omitted or None, strip leading and trailing ASCII whitespace.

val translate : ?delete:Py.Object.t -> table:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return a copy with each character mapped by the given translation table.

table Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

val zfill : width:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.