The unofficial CircuitPython Reference

module use

description

CircuitPython is designed in a modular fashion (as is Python) to reduce the memory size of programs. In every CircuitPython program it is therefore necessary to specify modules to access the classes and methods they contain.  The import keyword is used to access specific modules in Python and CircuitPython.

syntax

Import a module:

import <moduleName>

Access global variable from module:

moduleName.varibleName

Access method from module:

moduleName.methodName(argument)

Import part of a module:

from <moduleName> import <moduleSection>, <*optional* etc.>

Access global variable from module part:

moduleSection.varibleName

Access method from module part:

moduleSection(argument)

methods

parameters

returns

example code

serial output:

see also: