Built-in classes and functions

Classes and types

class bool
class bool(x: Any)

Returns a Boolean value, i.e. one of True or False.

x is converted using the standard truth testing procedure. If x is false or omitted, this returns False; otherwise it returns True.

class bytes
class bytes(source: Union[int, bytes, Iterable[int]])
class bytes(source: str, encoding: str)
class bytes(source: str, encoding: str, errors: str)

Returns a new bytes object, which is an immutable sequence of integers in the range 0 <= x <= 255.

class complex
class complex(real: Union[float, SupportsFloat, complex, SupportsComplex])
class complex(real: Union[float, SupportsFloat, complex, SupportsComplex], imag: Union[float, SupportsFloat, complex, SupportsComplex])
class complex(value: str)

Returns a complex number with the value real + imag*1j or converts a string or number to a complex number.

Note

This type is not available on the BOOST Move hub.

class dict(*args, **kwargs)

Creates a new dictionary.

class float
class float(x: int)
class float(x: SupportsFloat)
class float(x: str)

Returns a floating point number constructed from a number or string x.

class int
class int(x: str)
class int(x: str, base: int)
class int(x: Union[int, SupportsInt])

Returns an integer object constructed from a number or string x, or returns 0 if no arguments are given.

to_bytes(length: int, byteorder: Literal[little, big])bytes

Returns an array of bytes representing an integer.

from_bytes = None
class list
class list(iterable: Iterable)

Creates a new list.

class object

Return a new featureless object.

class range(stop: int)
class range(start: int, stop: int)
class range(start: int, stop: int, step: int)

Rather than being a function, range is actually an immutable sequence _type.

class slice(stop: int)
class slice(start: int, stop: int)
class slice(start: int, stop: int, step: int)

Returns a slice object representing the set of indices specified by range(start, stop, step).

Slice objects are also generated when extended indexing syntax is used. For example: a[start:stop:step] or a[start:stop, i].

Note

This type is not available on the BOOST Move hub.

class str(object: Any = '')
class str(object: bytes = b'', encoding: str = 'utf-8', errors: str = 'strict')

Return a str version of object.

class tuple
class tuple(iterable: Iterable)

Rather than being a function, tuple is actually an immutable sequence type.

class type(object: Any)

With one argument, returns the _type of an object.

Conversion functions

bin(x: Any)str

Converts an integer number to a binary string prefixed with “0b”. The result is a valid Python expression. If x is not a Python int object, it has to define an __index__() method that returns an integer.

chr(i: int)str

Returns the string representing a character whose Unicode code point is the integer i. For example, chr(97) returns the string 'a'.

This is the inverse of ord().

hex(x: int)str

Converts an integer number to a lowercase hexadecimal string prefixed with “0x”.

oct(x: int)str

Converts an integer number to an octal string prefixed with “0o”.

ord(c: str)int

Given a string representing one Unicode character, return an integer representing the Unicode code point of that character.

This is the inverse of chr().

repr(object: Any)str

Returns a string containing a printable representation of an object.

Input/output functions

input()str
input(prompt: str)str

If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.

Note

This function is not available on the BOOST Move hub.

print(*objects, sep: str = ' ', end: str = '\n', file: uio.FileIO = <uio.FileIO object>)

Prints objects to the text stream file, separated by sep and followed by end. sep, end and file, if present, must be given as keyword arguments.

Note

The file argument is not supported on the BOOST Move hub.