mpremote exec: semicolon for "one-liners" works. Will it alway work? #11576
Replies: 2 comments 5 replies
-
This is standard Python (and therefore MicroPython). Semicolons are optional as a statement separator in Python. |
Beta Was this translation helpful? Give feedback.
-
Here's a couple one-liners I came up with in the end... Show the files in a directory:
Show the subdirs in a directory:
My goal was to use |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been looking for a way to run multiple MicroPython statements on one line using
mpremote exec
. It seems the semicolon works similar to the way one would expect in a BASH shell.This is fabulous, but also unexpected since Python doesn't end lines with semicolons like other languages.
mpremote exec
doesn't seem to mind the spaces trailing the semicolon either. Serendipity!But, didn't see this feature mentioned in any documentation.
I'm happy it works, but is it an intentional feature? If I start writing exec strings like BASH one-liners will it break in some future release of mpremote?
Beta Was this translation helpful? Give feedback.
All reactions