Friday, March 20, 2026

A stupid MicroPython quirk

For an index to all my stories click this text

Here is a small and stupid MicroPython / Python quirk.
I blundered into this when I made an error in one of my programs.

Both MicroPython and Python have this stupid quirk: they see _ (underscore) as a normal variable.

for _ in range(10):
       print("This is stupid :")
       print(_)


Just look at this example.
You would not expect this to work. But look at the output in Thonny's shell:


So be careful with your variables. A typo can have strange results.

Till next time,
have fun

Luc Volders