Version: 1.1.0
Modules and packages
A Mojo file is a module. A directory with an __init__.mojo is a package. Other files import names from either one.
Essentials
import maththen callmath.sqrt.from math import sqrtbinds the name locally.- The package name matches the folder name.
- Cycles between modules are a design problem, not a feature.
- Tests can live beside the code or in a
testpackage.
Example
from math import sqrt
def main():
print(sqrt(2.0))
Keep in mind
See Packaging when the module should be installed by other projects.