This page (revision-21) was last changed on 2025-07-30 13:27 by Murray Altheim

This page was created on 2025-07-30 02:24 by Murray Altheim

Only authorized users are allowed to rename pages.

Only authorized users are allowed to delete pages.

Page revision history

Version Date Modified Size Author Changes ... Change note
21 2025-07-30 13:27 826 bytes Murray Altheim to previous

Page References

Incoming links Outgoing links

Version management

Difference between version and

At line 3 removed one line
%%info
At line 5 removed one line
%%
At line 5 added one line
The file {{main.py}} is special in MicroPython, in the sense that when you power-on the device and/or press the reset button, the main.py file is executed.
At line 8 removed 2 lines
The file (also sometimes called a "script") named {{main.py}} is special in MicroPython, in the sense that when you power-on the device and/or press the reset button, the contents of the {{main.py}} file are passed to the MicroPython interpreter and the program contained within main.py is executed. It's the ''entry point'' for running any application in Python.
At line 11 changed one line
%%python \\# this is a comment
%%python
\\# this is a comment
At line 14 changed one line
print("hello again.") # you can use single or double quotes
print("hello again.")
At line 18 changed one line
__See also:__ [The REPL|MicroPythonTutorialTheREPL]
!! The REPL
At line 18 added 40 lines
__REPL__ stands for ''Read, Evaluate, Print, Loop''. The REPL is how you interact with the Python Interpreter.
Unlike running a file containing Python code, in the REPL you can type commands and instantly see the output
printed out. You can also use the REPL to print out help for methods and objects in Python, list out what
methods are available, and much more.
We'll use the REPL to execute our main.py program. Depending on how you are using Python, you can access the REPL
on a command line, using a command line application (like mpremote or rshell), or within the user interface of a
Python IDE (Integrated Development Environment) like Thonny.
No matter how you get access to the REPL, once you see its command line you can type commands, hitting {{{RETURN}}}
to execute them.
On Linux or the Terminal in Mac OS:
%%repl {{{
► python3
Python 3.10.12 (main, May 27 2025, 17:12:29) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print('hello.')
hello.
>>>
}}} %%
Or using rshell, let's execute our main.py script:
%%repl {{{
/pyboard> repl
Entering REPL. Use Control-X to exit.
>
MicroPython v1.25.0 on 2025-04-15; Raspberry Pi Pico with RP2040
Type "help()" for more information.
>>>
>>> import main
hello world.
hello again.
>>>
}}} %%