MicroPython Standard Library

Pycardium contains some modules from the MicroPython standard library. These are:

framebuf

Refer to the official MicroPython docs for framebuf.

ubinascii

Refer to the official MicroPython docs for ubinascii.

ucollections

ucollections.namedtuple(...)

See the official MicroPython docs for namedtuple for details.

uerrno

Refer to the offical MicroPython docs for uerrno.

uheapq

Refer to the offical MicroPython docs for uheapq.

uio

Refer to the offical MicroPython docs for uio.

ujson

Refer to the offical MicroPython docs for ujson.

urandom

Pseudo-random number generator.

urandom.choice(seq)

Return a random element from the non-empty sequence seq.

urandom.getrandbits(k)

Returns a Python integer with k random bits.

urandom.randint(a, b)

Return a random integer N such that a <= N <= b. Alias for randrange(a, b+1).

urandom.random()

Return the next random floating point number in the range [0.0, 1.0).

urandom.randrange(start, stop[, step])
urandom.randrange(stop)

Return a randomly selected element from range(start, stop, step). This is equivalent to urandom.choice(range(start, stop, step)), but doesn’t actually build a range object.

The positional argument pattern matches that of range(). Keyword arguments should not be used because the function may use them in unexpected ways.

urandom.seed(n)

Seed the pseudo-random number generator from n.

Note

CPython does not provide a seed() function. This is a difference in the MicroPython implementation.

urandom.uniform(a, b)

Return a random floating point number N such that a <= N <= b for a <= b and b <= N <= a for b < a.

The end-point value b may or may not be included in the range depending on floating-point rounding in the equation a + (b-a) * random().

ure

Minimal regular expression library. Refer to the offical MicroPython docs for ure.

ustruct

Refer to the offical MicroPython docs for ustruct.

utime

utime contains non-standard functions as well. Please refer to our dedicated utime docs.

Python Standard Library

Additionally to the MicroPython module, Pycardium contains a subset of the CPython standard library, as implemented by micropython-lib. The following modules are included:

collections

Collections module.

contextlib

Contextlib module.

functools

Functools module.

itertools

Itertools module.

Warning

itertools.tee() is not implemented correctly.

string

String module.

struct

Struct module.

uuid

class uuid.UUID(hex=None, bytes=None, int=None, version=None)[source]

Create a new UUID object.

Exactly one of hex, bytes, or int must be given. The version argument is optional; if given, the resulting UUID will have its variant and version set according to RFC 4122, overriding the given hex, bytes, or int.

Examples:

UUID('{12345678-1234-5678-1234-567812345678}')
UUID('12345678123456781234567812345678')
UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
UUID(bytes='\x12\x34\x56\x78' * 4)
UUID(int=0x12345678123456781234567812345678)

New in version 1.10.

bytes

UUID as bytes() object

node

Node of this UUID

hex

Hex-String representation of this UUID

version

UUID version accordiung to RFC 4122

uuid.uuid4()[source]

Generate a new UUID version 4 (random UUID).

New in version 1.10.