What interprets python code on an m0 board?

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
kekerino
 
Posts: 24
Joined: Wed Jan 27, 2016 4:48 pm

What interprets python code on an m0 board?

Post by kekerino »

I want to know the name of the OS or shell or interpreter program that is running at a lower level on my Trinket M0. Whenever I ctrl-c and exit the running python program in the shell, I'm just like, "Okay, what shell am I actually in?" I'm assuming it's not Bash because it's not Linux, but then what? Can I run a python program from inside whatever shell it is? Eg; If I have main1.py and main2.py, can I direct the shell to open and run one of them? Can I run specific functions from within the shell? Or are ctrl-c and ctrl-d the only commands? They're all I know of, anyway.

User avatar
danhalbert
 
Posts: 4649
Joined: Tue Aug 08, 2017 12:37 pm

Re: What interprets python code on an m0 board?

Post by danhalbert »

It's not a shell per se, it's the CircuitPython "Read Eval Print Loop" (REPL). The REPL reads a Python expression or statement and executes it. So you can type Python at it and the Python gets executed.

Regular Python (e.g. from https://python.org) also has a REPL. Many interpreted languages do.

If you have `main1.py` stored in CIRCUITPY, you can run it once by typing `import main1`. But the main point of doing `import` is to define a bunch of functions, classes or variables, not to run a piece of code. So if you do `import main1`, it will not re-run the program. To run it again, type ctrl-D, which restarts CircuitPython fresh, and then import it again.

There are operating-system-like things you can do. For instance,

Code: Select all

import os
os.listdir()

User avatar
kekerino
 
Posts: 24
Joined: Wed Jan 27, 2016 4:48 pm

Re: What interprets python code on an m0 board?

Post by kekerino »

Thanks, it helps me understand what is going on a little more.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”