Skip to content

Commit 6c4a6dc

Browse files
rayluodlech
authored andcommitted
Mentions how micropython is run differently
1 parent 3e1cd08 commit 6c4a6dc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

docs/programming-languages.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,28 @@ This brings some advantages, like programs starting significantly faster than
5050
regular Python, but comes at the cost at not being fully compatible with code
5151
written for regular Python.
5252

53+
MicroPython works as a different Python interpreter, rather than as a library.
54+
It can be invoked by running it from the command line, for example:
55+
`micropython -c "import sys; print(sys.version)"` or
56+
`micropython -c "from ev3dev2.sound import Sound; Sound().speak('hello world')"`.
57+
You may add this as the first line of your Python script to run it with MicroPython:
58+
`#!/usr/bin/env micropython`.
59+
60+
**TIP:** `ev3dev-lang-python` is also partially compatible with MicroPython.
61+
5362
[Pybricks] is a specialized version of MicroPython for LEGO MINDSTORMS and LEGO
5463
Powered Up smart hubs. Pybricks v2.0 is used by LEGO Education as their [Python
5564
for EV3](https://education.lego.com/en-us/product-resources/mindstorms-ev3/teacher-resources/python-for-ev3)
5665
solution and is the same version that is available in ev3dev-stretch.
5766

58-
**TIP:** `ev3dev-lang-python` is also partially compatible with MicroPython.
67+
You may run Pybricks from command line like this:
68+
`brickrun -r -- pybricks-micropython -c "from pybricks.hubs import EV3Brick; EV3Brick().speaker.beep()"`.
69+
You may add this as the first line of your Python script,
70+
`#!/usr/bin/env pybricks-micropython`,
71+
and then run it from the brick's file browser to run it with Pybricks.
72+
73+
**TIP:** If you are into using Python's interactive mode when trying Pybricks,
74+
you can use `brickrun -r -- pybricks-micropython`, or its shortcut `pybricks-repl`.
5975

6076
[Get started with MicroPython](https://pybricks.github.io/ev3-micropython/){: .btn .btn-default }
6177

0 commit comments

Comments
 (0)